<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge" >
  <link rel="dns-prefetch" href="http://example.com">
  <title>DustWind&#39;s Blog</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta property="og:type" content="website">
<meta property="og:title" content="DustWind&#39;s Blog">
<meta property="og:url" content="http://example.com/index.html">
<meta property="og:site_name" content="DustWind&#39;s Blog">
<meta property="og:locale" content="zh_CN">
<meta property="article:author" content="DustWind">
<meta name="twitter:card" content="summary">
  
    <link rel="alternative" href="/atom.xml" title="DustWind&#39;s Blog" type="application/atom+xml">
  
  
    <link rel="icon" href="/favicon.png">
  
  <link rel="stylesheet" type="text/css" href="/./main.0cf68a.css">
  <style type="text/css">
  
    #container.show {
      background: linear-gradient(200deg,#a0cfe4,#e8c37e);
    }
  </style>
  

  

<meta name="generator" content="Hexo 7.0.0"></head>

<body>
  <div id="container" q-class="show:isCtnShow">
    <canvas id="anm-canvas" class="anm-canvas"></canvas>
    <div class="left-col" q-class="show:isShow">
      
<div class="overlay" style="background: #4d4d4d"></div>
<div class="intrude-less">
	<header id="header" class="inner">
		<a href="/" class="profilepic">
			<img src="/img/vae.jpg" class="js-avatar">
		</a>
		<hgroup>
		  <h1 class="header-author"><a href="/"></a></h1>
		</hgroup>
		

		<nav class="header-menu">
			<ul>
			
				<li><a href="/">DustWind</a></li>
	        
			</ul>
		</nav>
		<nav class="header-smart-menu">
    		
    			
    			<a q-on="click: openSlider(e, 'innerArchive')" href="javascript:void(0)">所有文章</a>
    			
            
    			
    			<a q-on="click: openSlider(e, 'friends')" href="javascript:void(0)">友链</a>
    			
            
    			
    			<a q-on="click: openSlider(e, 'aboutme')" href="javascript:void(0)">关于我</a>
    			
            
		</nav>
		<nav class="header-nav">
			<div class="social">
				
					<a class="github" target="_blank" href="https://github.com/DustWind97" title="github"><i class="icon-github"></i></a>
		        
					<a class="bilibili" target="_blank" href="https://space.bilibili.com/11246855?spm_id_from=333.1007.0.0" title="bilibili"><i class="icon-bilibili"></i></a>
		        
					<a class="qq" target="_blank" href="/img/myQQ.jpg" title="qq"><i class="icon-qq"></i></a>
		        
					<a class="mail" target="_blank" href="/img/MailQR.png" title="mail"><i class="icon-mail"></i></a>
		        
			</div>
		</nav>
	</header>		
</div>

    </div>
    <div class="mid-col" q-class="show:isShow,hide:isShow|isFalse">
      
<nav id="mobile-nav">
  	<div class="overlay js-overlay" style="background: #4d4d4d"></div>
	<div class="btnctn js-mobile-btnctn">
  		<div class="slider-trigger list" q-on="click: openSlider(e)"><i class="icon icon-sort"></i></div>
	</div>
	<div class="intrude-less">
		<header id="header" class="inner">
			<div class="profilepic">
				<img src="/img/vae.jpg" class="js-avatar">
			</div>
			<hgroup>
			  <h1 class="header-author js-header-author"></h1>
			</hgroup>
			
			
			
				
			
			
			
			<nav class="header-nav">
				<div class="social">
					
						<a class="github" target="_blank" href="https://github.com/DustWind97" title="github"><i class="icon-github"></i></a>
			        
						<a class="bilibili" target="_blank" href="https://space.bilibili.com/11246855?spm_id_from=333.1007.0.0" title="bilibili"><i class="icon-bilibili"></i></a>
			        
						<a class="qq" target="_blank" href="/img/myQQ.jpg" title="qq"><i class="icon-qq"></i></a>
			        
						<a class="mail" target="_blank" href="/img/MailQR.png" title="mail"><i class="icon-mail"></i></a>
			        
				</div>
			</nav>

			<nav class="header-menu js-header-menu">
				<ul style="width: 50%">
				
				
					<li style="width: 100%"><a href="/">DustWind</a></li>
		        
				</ul>
			</nav>
		</header>				
	</div>
	<div class="mobile-mask" style="display:none" q-show="isShow"></div>
</nav>

      <div id="wrapper" class="body-wrap">
        <div class="menu-l">
          <div class="canvas-wrap">
            <canvas data-colors="#eaeaea" data-sectionHeight="100" data-contentId="js-content" id="myCanvas1" class="anm-canvas"></canvas>
          </div>
          <div id="js-content" class="content-ll">
            
  
    <article id="post-Manjaro桌面图标创建" class="article article-type-post  article-index" itemscope itemprop="blogPost">
  <div class="article-inner">
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/2024/02/23/Manjaro%E6%A1%8C%E9%9D%A2%E5%9B%BE%E6%A0%87%E5%88%9B%E5%BB%BA/">Manjaro桌面快捷方式创建</a>
    </h1>
  

        
        <a href="/2024/02/23/Manjaro%E6%A1%8C%E9%9D%A2%E5%9B%BE%E6%A0%87%E5%88%9B%E5%BB%BA/" class="archive-article-date">
  	<time datetime="2024-02-23T13:19:21.000Z" itemprop="datePublished"><i class="icon-calendar icon"></i>2024-02-23</time>
</a>
        
      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <h1 id="引言"><a href="#引言" class="headerlink" title="引言"></a>引言</h1><p>在 Manjaro 系统日常使用中，有的软件点击率和使用率更高，因此这就需要使用更方便的访问方式，而桌面图标就能满足这一需求。在 Windows 系统中可直接将可执行程序（EXE程序）以创建快捷链接的方式实现桌面访问，而 Linux 系统需要自己创建 desktop 文件并修改相应键值对来达到桌面访问的目的。本文以下部分将阐述具体的实现方式。</p>
<h1 id="一-了解-desktop-文件"><a href="#一-了解-desktop-文件" class="headerlink" title="一.了解 desktop 文件"></a>一.了解 desktop 文件</h1><p>为了描述如何启动特定程序、如何在菜单中显示等功能，采用配置文件的方式写入相关信息可大大简化维护的时间成本。 <code>Desktop Entry</code> 配置文件就是在这样的背景下应运而生的，像诸如 <code>KDE</code> 、 <code>GNOME</code> 等桌面环境都采用了这一方式。</p>
<h2 id="1-1-编写说明"><a href="#1-1-编写说明" class="headerlink" title="1.1 编写说明"></a>1.1 编写说明</h2><p>desktop 文件有诸多语法规则和编写相关的配置操作。部分细节如下所示，更加完整的规则可参阅文档： <a target="_blank" rel="noopener" href="https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html#recognized-keys">Desktop Entry Specification</a> </p>
<ol>
<li><p>Desktop Entry 文件采用 UTF-8 编码。</p>
</li>
<li><p>Desktop Entry 文件命名采用 <code>.desktop</code> 后缀</p>
</li>
<li><p>使用 <code>#</code> 号书写备注信息</p>
</li>
<li><p>此文件所有内容采用 <code>键值对</code> 格式书写</p>
</li>
<li><p>关键字可以选择进行本地化显示，具体的细则如下表：</p>
</li>
</ol>
<table>
<thead>
<tr>
<th align="center">LC_MESSAGES Value</th>
<th align="center">可选值</th>
</tr>
</thead>
<tbody><tr>
<td align="center">lang_COUNTRY@MODIFIER</td>
<td align="center">lang_COUNTRY@MODIFIER，lang_COUNTRY，lang@MODIFIER，lang，默认值</td>
</tr>
<tr>
<td align="center">lang_COUNTRY</td>
<td align="center">lang_COUNTRY，lang，默认值</td>
</tr>
<tr>
<td align="center">lang@MODIFIER</td>
<td align="center">lang@MODIFIER，lang，默认值</td>
</tr>
<tr>
<td align="center">lang</td>
<td align="center">lang，默认值</td>
</tr>
</tbody></table>
<p>具体书写方式为</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">`[ ]` 内的内容为可选项，非必须</span></span><br><span class="line">key[LC_MESSAGES Value]=value</span><br></pre></td></tr></table></figure>



<h2 id="1-2-编写规则"><a href="#1-2-编写规则" class="headerlink" title="1.2 编写规则"></a>1.2 编写规则</h2><p>要想创建桌面图标，首先需要了解桌面项的编写方式，具体可参考文档： <a target="_blank" rel="noopener" href="https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html#recognized-keys">Desktop Entry Specification Version 1.5</a> 。</p>
<p>此文件的最重要内容是键值对，关键字的选取尤为关键，每个桌面项<strong>必须</strong>具有一个<code>Type</code>关键字和一个<code>Name</code>关键字，其他项定义应用程序菜单中的外观（<strong>非必须</strong>）。下面是此版本关键字的摘要表格。</p>
<table>
<thead>
<tr>
<th align="center">序号</th>
<th align="center">关键字</th>
<th align="center">值类型</th>
<th align="center">是否必须</th>
<th align="center">应用类型</th>
<th align="center">描述</th>
</tr>
</thead>
<tbody><tr>
<td align="center">1</td>
<td align="center">Type</td>
<td align="center">string</td>
<td align="center">必须</td>
<td align="center">&#x2F;</td>
<td align="center">类型</td>
</tr>
<tr>
<td align="center">2</td>
<td align="center">Version</td>
<td align="center">string</td>
<td align="center">非必须</td>
<td align="center">Type 1-3</td>
<td align="center">版本</td>
</tr>
<tr>
<td align="center">3</td>
<td align="center">Name</td>
<td align="center">localestring</td>
<td align="center">必须</td>
<td align="center">Type 1-3</td>
<td align="center">名称</td>
</tr>
<tr>
<td align="center">4</td>
<td align="center">GenericName</td>
<td align="center">localestring</td>
<td align="center">非必须</td>
<td align="center">Type 1-3</td>
<td align="center">通用名</td>
</tr>
<tr>
<td align="center">5</td>
<td align="center">NoDisplay</td>
<td align="center">boolean</td>
<td align="center">非必须</td>
<td align="center">Type 1-3</td>
<td align="center">不显示</td>
</tr>
<tr>
<td align="center">6</td>
<td align="center">Comment</td>
<td align="center">localestring</td>
<td align="center">非必须</td>
<td align="center">Type 1-3</td>
<td align="center">备注信息</td>
</tr>
<tr>
<td align="center">7</td>
<td align="center">Icon</td>
<td align="center">iconstring</td>
<td align="center">非必须</td>
<td align="center">Type 1-3</td>
<td align="center">图标</td>
</tr>
<tr>
<td align="center">8</td>
<td align="center">Hidden</td>
<td align="center">boolean</td>
<td align="center">非必须</td>
<td align="center">Type 1-3</td>
<td align="center">隐藏项</td>
</tr>
<tr>
<td align="center">9</td>
<td align="center">OnlyShowIn，NotShowIn</td>
<td align="center">string(s)</td>
<td align="center">非必须</td>
<td align="center">Type 1-3</td>
<td align="center">显示项</td>
</tr>
<tr>
<td align="center">10</td>
<td align="center">DBusActivatable</td>
<td align="center">boolean</td>
<td align="center">非必须</td>
<td align="center">&#x2F;</td>
<td align="center">D-Bus 选项</td>
</tr>
<tr>
<td align="center">11</td>
<td align="center">TryExec</td>
<td align="center">string</td>
<td align="center">非必须</td>
<td align="center">Type 1</td>
<td align="center">尝试执行</td>
</tr>
<tr>
<td align="center">12</td>
<td align="center">Exec</td>
<td align="center">string</td>
<td align="center">非必须</td>
<td align="center">Type 1</td>
<td align="center">执行</td>
</tr>
<tr>
<td align="center">13</td>
<td align="center">Path</td>
<td align="center">string</td>
<td align="center">非必须</td>
<td align="center">Type 1</td>
<td align="center">路径</td>
</tr>
<tr>
<td align="center">14</td>
<td align="center">Terminal</td>
<td align="center">boolean</td>
<td align="center">非必须</td>
<td align="center">Type 1</td>
<td align="center">终端</td>
</tr>
<tr>
<td align="center">15</td>
<td align="center">Actions</td>
<td align="center">string(s)</td>
<td align="center">非必须</td>
<td align="center">Type 1</td>
<td align="center">行为</td>
</tr>
<tr>
<td align="center">16</td>
<td align="center">MimeType</td>
<td align="center">string(s)</td>
<td align="center">非必须</td>
<td align="center">Type 1</td>
<td align="center">MIME 类型</td>
</tr>
<tr>
<td align="center">17</td>
<td align="center">Categories</td>
<td align="center">string(s)</td>
<td align="center">非必须</td>
<td align="center">Type 1</td>
<td align="center">类型</td>
</tr>
<tr>
<td align="center">18</td>
<td align="center">Implements</td>
<td align="center">string(s)</td>
<td align="center">非必须</td>
<td align="center">&#x2F;</td>
<td align="center">执行</td>
</tr>
<tr>
<td align="center">19</td>
<td align="center">Keywords</td>
<td align="center">localestring(s)</td>
<td align="center">非必须</td>
<td align="center">Type 1</td>
<td align="center">关键词</td>
</tr>
<tr>
<td align="center">20</td>
<td align="center">StartupNotify</td>
<td align="center">boolean</td>
<td align="center">非必须</td>
<td align="center">Type 1</td>
<td align="center">-</td>
</tr>
<tr>
<td align="center">21</td>
<td align="center">StartupWMClass</td>
<td align="center">string</td>
<td align="center">非必须</td>
<td align="center">Type 1</td>
<td align="center">-</td>
</tr>
<tr>
<td align="center">22</td>
<td align="center">URL</td>
<td align="center">string</td>
<td align="center">必须</td>
<td align="center">Type 2</td>
<td align="center">链接</td>
</tr>
<tr>
<td align="center">23</td>
<td align="center">PrefersNonDefaultGPU</td>
<td align="center">boolean</td>
<td align="center">非必须</td>
<td align="center">Type 1</td>
<td align="center">默认显卡</td>
</tr>
<tr>
<td align="center">24</td>
<td align="center">SingleMainWindow</td>
<td align="center">boolean</td>
<td align="center">非必须</td>
<td align="center">Type 1</td>
<td align="center">单窗口</td>
</tr>
</tbody></table>
<blockquote>
<p><strong>注</strong>：</p>
<ol>
<li><code>string</code>  类型可以是包含 ASCII 码中除控制符外的所有字符。</li>
<li><code>localestring</code> 类型是用户可见的字符类型，通常采用 UTF-8 编码。</li>
<li><code>iconstring</code>  与 <code>localestring</code> 类型大体上一致，只是用户不可见。同样采用 UTF-8 编码。</li>
<li><code>boolean</code>为布尔类型</li>
</ol>
</blockquote>
<h3 id="1-2-1-关键字详细说明"><a href="#1-2-1-关键字详细说明" class="headerlink" title="1.2.1 关键字详细说明"></a>1.2.1 关键字详细说明</h3><p>对表格的详细说明如下：</p>
<ol>
<li><p>Type<code> 关键字</code> ：指定 <code>Desktop Entry</code> 的类型。在 Version 1.5 规范中定义了三种类型：&#96; </p>
<ol>
<li><p>Type1 ： <code>Application</code></p>
</li>
<li><p>Type2 ： <code>Link</code></p>
</li>
<li><p>Type3 ： <code>Directory</code></p>
</li>
</ol>
</li>
<li><p><code>Version</code> 关键字：指定<code>Desktop Entry</code> 的版本号。</p>
</li>
<li><p><code>Name</code> 关键字：指定应用程序的名称。</p>
</li>
<li><p><code>GenericName</code> 关键字：指定应用程序的通用名。</p>
</li>
<li><p><code>NoDisplay</code>  关键字：这个关键字的意思是：“此应用已存在，不在开始菜单显示”。</p>
</li>
<li><p><code>Comment</code>  关键字：对于 <code>Name</code> 和 <code>GenericName</code> 关键字的简短解释说明。</p>
</li>
<li><p><code>Icon</code>  关键字：指定此应用程序在应用程序浏览器或是在文件浏览器中所显示的图标。一般以绝对路径形式提供。</p>
</li>
<li><p><code>Hidden</code>  关键字：此项对已删除的应用或者已卸载仍存在的文件适用。</p>
</li>
<li><p><code>OnlyShowIn，NotShowIn</code>  关键字：指定（只显示&#x2F;不显示）在某个桌面环境上。这一字段可对应多个数值。</p>
</li>
<li><p><code>DBusActivatable</code>  关键字：D-Bus 消息管理机制的支持。默认值为 false 。此项为 true 值时会默认调用 D-Bus 而忽略掉 Exec 关键字去执行该应用程序。</p>
</li>
<li><p><code>TryExec</code>  关键字：用以确定一个可执行文件是否已实际安装的路径</p>
</li>
<li><p><code>Exec</code>  关键字：指定可执行程序（可带参数）  ，这一关键字在 <code>DBusActivatable</code> 字段为 false 时生效。这一字段必须存在，以实现兼容性。此关键字的具体介绍可看 <strong>1.2.2 节</strong> 。</p>
</li>
<li><p><code>Path</code>  关键字：指定程序运行的 <code>bin</code> 目录。</p>
</li>
<li><p><code>Terminal</code>  关键字：确定应用程序的运行是否依赖终端窗口。</p>
</li>
<li><p><code>Actions</code>  关键字：标识应用程序行为，这一字段能告诉应用程序执行更具体的操作（一种行为代表一种调用此程序的方式），通俗讲就是此应用程序的鼠标右键功能选项和程序附加应用程序功能。指定的每种行为需要在文件当中新开一个 Group Header。 此关键字的具体介绍可看 <strong>1.2.3 节</strong> 。</p>
</li>
<li><p><code>MimeType</code>  关键字：此字段用于指定此应用程序支持的 <code>MIME类型</code> （全称 Multipurpose Internet Mail Extensions，是一种用于定义文档、文件或字节流的性质和格式的标准）。</p>
</li>
<li><p><code>Categories</code>  关键字：此字段指定该 <code>Desktop Entry</code> 在开始菜单中显示的类别，可指定多个数值，但默认第一个数值。更加详细的菜单项可查看技术文档：<a target="_blank" rel="noopener" href="https://specifications.freedesktop.org/menu-spec/latest/apa.html#main-category-registry">Desktop Menu Specification</a> 。此关键字的具体介绍可看 <strong>1.2.4 节</strong> 。</p>
</li>
<li><p><code>Implements</code>  关键字：此字段用于指定 <code>D-Bus</code> 一个或者更多接口名。这一关键字需要 <code>DBusActivatable</code> 字段为 true 时生效。</p>
</li>
<li><p><code>Keywords</code>  关键字：指定此字段可以在开始菜单更方便地搜索到此应用。可以指定多个字符串来描述此应用。当然，此字段不应当与 <code>Name</code> 字段和 <code>GenericName</code> 字段重复。</p>
</li>
<li><p><code>StartupNotify</code>  关键字：更加完整的协议内容可查看技术文档： <a target="_blank" rel="noopener" href="http://www.freedesktop.org/Standards/startup-notification-spec">Startup Notification Protocol Specification</a> 。</p>
</li>
<li><p><code>StartupWMClass</code>  关键字：更加完整的协议内容可查看技术文档： <a target="_blank" rel="noopener" href="http://www.freedesktop.org/Standards/startup-notification-spec">Startup Notification Protocol Specification</a> 。</p>
</li>
<li><p><code>URL</code>  关键字：当 <code>Type</code> 类型为 <code>Link</code> 时此关键字段是必须的，具体功能时指定具体的链接</p>
</li>
<li><p><code>PrefersNonDefaultGPU</code>  关键字：这是一个提示性关键字，不是强制性的。如果此字段为 true ，则该程序默认运行在独立显卡上；如果为 false ，则该程序运行在集成显卡上。</p>
</li>
<li><p><code>SingleMainWindow</code>  关键字：这是一个提示性关键字，不是强制性的。用于指定是否单窗口运行，如果为 true ，应用只单窗口运行；如果为 flase ，则可多开窗口。</p>
</li>
</ol>
<h3 id="1-2-2-Exec-关键字（第-12-项）"><a href="#1-2-2-Exec-关键字（第-12-项）" class="headerlink" title="1.2.2 Exec 关键字（第 12 项）"></a>1.2.2 Exec 关键字（第 12 项）</h3><p>此关键字用于指定一个或多个参数的可执行程序。指定该可执行程序的方式可以是：<strong>绝对路径</strong>或<strong>此可执行程序的名称</strong>。如果未提供此项，则会在 path 环境变量中去查找可执行文件。</p>
<p><code>Field Code</code> 码的作用：</p>
<ol>
<li><code>%f</code> ： 传递<strong>单本地文件</strong>给本 Desktop Entry 文件。</li>
<li><code>%F</code> ： 传递<strong>多本地文件</strong>给本 Desktop Entry 文件。</li>
<li><code>%u</code> ： 传递<strong>单个 URL 或者单个本地路径</strong>给本 Desktop Entry 文件。</li>
<li><code>%U</code> ： 传递<strong>多个 URL 或者多个本地路径</strong>给本 Desktop Entry 文件。</li>
<li><code>%i</code> ： 将 Icon 关键字扩展为两个参数。如果 Icon 关键字为空或无 Icon 关键字，则不应扩展为任何参数。</li>
<li><code>%c</code> ： 此文件中 Name 关键字所列出应用程序的翻译名称。</li>
<li><code>%k</code> ： 传入位置可以是 URI 或者本地文件名。如果不知道位置，则为空。</li>
</ol>
<blockquote>
<p><strong>注</strong>：</p>
<ol>
<li>此 Field Code 码只能从上述前四个中选取一个。这七个 Field Code 码不能在双引号中。</li>
<li>Field Code 是其他程序调用此 Desktop Entry 文件时传入的参数。</li>
</ol>
</blockquote>
<h3 id="1-2-3-Actions-关键字（第-15-项）"><a href="#1-2-3-Actions-关键字（第-15-项）" class="headerlink" title="1.2.3 Actions 关键字（第 15 项）"></a>1.2.3 Actions 关键字（第 15 项）</h3><p>一个 <code>Desktop Entry</code> 文件可以有一个或多个 <code>Actions</code> 。一个 Action 就对应一种调用此程序的方式。这一方式可以用来创建 Quicklists 或者 Jumplists 。</p>
<blockquote>
<p><strong>注</strong>：</p>
<p>一个 Desktop 文件的组成：</p>
<ol>
<li>一个 <code>[Desktop Entry]</code> 组成。必须。</li>
<li>若干个 <code>[Desktop Aciton &lt;Action Identifier&gt;]</code> 组成。非必须。</li>
</ol>
</blockquote>
<p>指定的每种 Action 都需要在文件当中新开一个 Group Header 。其关键字必须包含 <code>Name</code> ，而 <code>Icon</code> 和 <code>Exec</code> 关键字则非必须。</p>
<h3 id="1-2-4-Categories-关键字（第-17-项）"><a href="#1-2-4-Categories-关键字（第-17-项）" class="headerlink" title="1.2.4  Categories 关键字（第 17 项）"></a>1.2.4  Categories 关键字（第 17 项）</h3><p>在 Desktop Entry 文件中，可以有一个或者多个 Category ，但是默认选择 Main Category 生效。更多的 Category 项目可以参阅文档：<a target="_blank" rel="noopener" href="https://specifications.freedesktop.org/menu-spec/latest/apas02.html">Additional Category</a> 。</p>
<table>
<thead>
<tr>
<th align="center">Main Category</th>
<th align="center">描述</th>
<th align="center">备注</th>
</tr>
</thead>
<tbody><tr>
<td align="center">Audio Video</td>
<td align="center">多媒体音视频</td>
<td align="center">-</td>
</tr>
<tr>
<td align="center">Audio</td>
<td align="center">音频程序</td>
<td align="center">选择此字段则也须包括 Audio Video 字段</td>
</tr>
<tr>
<td align="center">Video</td>
<td align="center">视频程序</td>
<td align="center">选择此字段则也须包括 Audio Video 字段</td>
</tr>
<tr>
<td align="center">Development</td>
<td align="center">开发者程序</td>
<td align="center">-</td>
</tr>
<tr>
<td align="center">Education</td>
<td align="center">教育软件</td>
<td align="center">-</td>
</tr>
<tr>
<td align="center">Game</td>
<td align="center">游戏程序</td>
<td align="center">-</td>
</tr>
<tr>
<td align="center">Graphics</td>
<td align="center">浏览，处理图片程序</td>
<td align="center">-</td>
</tr>
<tr>
<td align="center">Network</td>
<td align="center">网络程序</td>
<td align="center">-</td>
</tr>
<tr>
<td align="center">Office</td>
<td align="center">办公软件</td>
<td align="center">-</td>
</tr>
<tr>
<td align="center">Science</td>
<td align="center">科学软件</td>
<td align="center">-</td>
</tr>
<tr>
<td align="center">Settings</td>
<td align="center">设置</td>
<td align="center">可能出现在单独菜单中，或者在控制中心中</td>
</tr>
<tr>
<td align="center">System</td>
<td align="center">系统软件，如日志文件软件</td>
<td align="center">-</td>
</tr>
<tr>
<td align="center">Utility</td>
<td align="center">实用程序，如 Accessories</td>
<td align="center">-</td>
</tr>
</tbody></table>
<h2 id="1-3-存放位置"><a href="#1-3-存放位置" class="headerlink" title="1.3 存放位置"></a>1.3 存放位置</h2><p>通常，通过包管理器或者自动安装的软件要么在用户条目目录下自动创建了 desktop 文件，要么就在系统目录下自动创建了 desktop 文件。在这两个目录下创建了 desktop 文件，访问图标将出现在 Linux 的开始菜单中。如果本人想要在桌面创建图标则需要在主目录的桌面文件夹下创建一个 desktop 文件。</p>
<h3 id="1-3-1-用户条目的-desktop-文件"><a href="#1-3-1-用户条目的-desktop-文件" class="headerlink" title="1.3.1 用户条目的 desktop 文件"></a>1.3.1 用户条目的 desktop 文件</h3><p>此文件夹下desktop 文件通常是安装软件后自动生成。具体目录如下所示：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">~/.local/share/application</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">等效于如下路径，其中 dustwind 为笔者的用户目录</span></span><br><span class="line">/home/dustwind/.local/share/applications</span><br></pre></td></tr></table></figure>



<blockquote>
<p><strong>注</strong>：</p>
<p>主目录等效于根目录的 home 目录下的用户目录，即：</p>
<p>～ 等效于 &#x2F;home&#x2F;{UserName} 目录</p>
</blockquote>
<h3 id="1-3-2-系统条目的-desktop-文件"><a href="#1-3-2-系统条目的-desktop-文件" class="headerlink" title="1.3.2 系统条目的 desktop 文件"></a>1.3.2 系统条目的 desktop 文件</h3><p>此文件夹下 desktop 文件通常是安装软件后自动生成。具体目录如下所示：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">通常的 Linux 系统是如下目录</span></span><br><span class="line">/usr/share/applications</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">有的 Linux 系统会是如下目录</span></span><br><span class="line">/usr/local/share/applications/</span><br></pre></td></tr></table></figure>



<blockquote>
<p><strong>注</strong>：</p>
<p>需要注意的是，<strong>用户条目</strong>下的文件优先级高于<strong>系统条目</strong>下的文件优先级</p>
</blockquote>
<h3 id="1-3-3-在桌面访问的-desktop-文件"><a href="#1-3-3-在桌面访问的-desktop-文件" class="headerlink" title="1.3.3 在桌面访问的 desktop 文件"></a>1.3.3 在桌面访问的 desktop 文件</h3><p>如果想要在桌面访问软件，则需要访问软件的 desktop 文件放到如下目录中并编辑对应的桌面项。</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">中文环境下为如下目录</span></span><br><span class="line">~/桌面</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">英文环境下为如下目录</span></span><br><span class="line">~/Desktop</span><br></pre></td></tr></table></figure>



<h1 id="二-实现-desktop-文件"><a href="#二-实现-desktop-文件" class="headerlink" title="二.实现 desktop 文件"></a>二.实现 desktop 文件</h1><p>这里以 google-chrome 软件为例编写 desktop 文件。具体可对照规格文档查看具体含义，这里就不再阐述。本章节的实现可以参考： <a target="_blank" rel="noopener" href="https://wiki.archlinuxcn.org/wiki/%E6%A1%8C%E9%9D%A2%E9%A1%B9">ArchWiki—桌面项</a></p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br></pre></td><td class="code"><pre><span class="line">[Desktop Entry]</span><br><span class="line">Version=1.0</span><br><span class="line">Name=Google Chrome</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">Only KDE 4 seems to use GenericName, so we reuse the KDE strings.</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">From Ubuntu<span class="string">&#x27;s language-pack-kde-XX-base packages, version 9.04-20090413.</span></span></span><br><span class="line">GenericName=Web Browser</span><br><span class="line">GenericName[en_GB]=Web Browser</span><br><span class="line">GenericName[zh_CN]=网页浏览器</span><br><span class="line">GenericName[zh_TW]=網頁瀏覽器</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash"><span class="string">Gnome and KDE 3 uses Comment.</span></span></span><br><span class="line">Comment=Access the Internet</span><br><span class="line">Comment[en_GB]=Access the Internet</span><br><span class="line">Comment[zh_CN]=访问互联网</span><br><span class="line">Comment[zh_TW]=連線到網際網路</span><br><span class="line">StartupWMClass=Google-chrome</span><br><span class="line">Exec=/usr/bin/google-chrome-stable %U</span><br><span class="line">StartupNotify=true</span><br><span class="line">Terminal=false</span><br><span class="line">Icon=google-chrome</span><br><span class="line">Type=Application</span><br><span class="line">Categories=Network;WebBrowser;</span><br><span class="line">MimeType=application/pdf;application/rdf+xml;application/rss+xml;application/xhtml+xml;application/xhtml_xml;application/xml;image/gif;image/jpeg;image/png;image/webp;text/html;text/xml;x-scheme-handler/http;x-scheme-handler/https;</span><br><span class="line">Actions=new-window;new-private-window;</span><br><span class="line"></span><br><span class="line">[Desktop Action new-window]</span><br><span class="line">Name=New Window</span><br><span class="line">Name[en_GB]=New Window</span><br><span class="line">Name[zh_CN]=新建窗口</span><br><span class="line">Name[zh_TW]=開新視窗</span><br><span class="line">StartupWMClass=Google-chrome</span><br><span class="line">Exec=/usr/bin/google-chrome-stable</span><br><span class="line"></span><br><span class="line">[Desktop Action new-private-window]</span><br><span class="line">Name=New Incognito Window</span><br><span class="line">Name[en_GB]=New Incognito window</span><br><span class="line">Name[zh_CN]=新建隐身窗口</span><br><span class="line">Name[zh_TW]=新增無痕式視窗</span><br><span class="line">StartupWMClass=Google-chrome</span><br><span class="line">Exec=/usr/bin/google-chrome-stable --incognito</span><br><span class="line"></span><br></pre></td></tr></table></figure>
























      

      
    </div>
    <div class="article-info article-info-index">
      
      
	<div class="article-tag tagcloud">
		<i class="icon-price-tags icon"></i>
		<ul class="article-tag-list">
			 
        		<li class="article-tag-list-item">
        			<a href="javascript:void(0)" class="js-tag article-tag-list-link color1">Linux</a>
        		</li>
      		 
        		<li class="article-tag-list-item">
        			<a href="javascript:void(0)" class="js-tag article-tag-list-link color3">Manjaro</a>
        		</li>
      		 
        		<li class="article-tag-list-item">
        			<a href="javascript:void(0)" class="js-tag article-tag-list-link color4">Desktop Entry</a>
        		</li>
      		
		</ul>
	</div>

      

      
        <p class="article-more-link">
          <a class="article-more-a" href="/2024/02/23/Manjaro%E6%A1%8C%E9%9D%A2%E5%9B%BE%E6%A0%87%E5%88%9B%E5%BB%BA/">展开全文 >></a>
        </p>
      

      
      <div class="clearfix"></div>
    </div>
  </div>
</article>

<aside class="wrap-side-operation">
    <div class="mod-side-operation">
        
        <div class="jump-container" id="js-jump-container" style="display:none;">
            <a href="javascript:void(0)" class="mod-side-operation__jump-to-top">
                <i class="icon-font icon-back"></i>
            </a>
            <div id="js-jump-plan-container" class="jump-plan-container" style="top: -11px;">
                <i class="icon-font icon-plane jump-plane"></i>
            </div>
        </div>
        
        
    </div>
</aside>




  
    <article id="post-Manjaro的软件安装方式" class="article article-type-post  article-index" itemscope itemprop="blogPost">
  <div class="article-inner">
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/2024/01/31/Manjaro%E7%9A%84%E8%BD%AF%E4%BB%B6%E5%AE%89%E8%A3%85%E6%96%B9%E5%BC%8F/">Manjaro的软件安装方式</a>
    </h1>
  

        
        <a href="/2024/01/31/Manjaro%E7%9A%84%E8%BD%AF%E4%BB%B6%E5%AE%89%E8%A3%85%E6%96%B9%E5%BC%8F/" class="archive-article-date">
  	<time datetime="2024-01-31T12:01:21.000Z" itemprop="datePublished"><i class="icon-calendar icon"></i>2024-01-31</time>
</a>
        
      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <h1 id="引言"><a href="#引言" class="headerlink" title="引言"></a>引言</h1><p>Linux 系统有着众多特点，而灵活性便是其中之一。而这一灵活性的具体体现就是软件的安装是可以通过多种方法途径来实现的。因此，掌握多种 Linux 系统上软件安装方法便是一个开发者以及爱好者的必备技能。本文以下部分将阐述笔者所了解掌握的几种 Linux 系统安装软件的方法。当然，这几种方法主要是 Arch 系发行版的 Linux 系统。</p>
<h1 id="一-通过-pacman-命令安装"><a href="#一-通过-pacman-命令安装" class="headerlink" title="一.通过 pacman 命令安装"></a>一.通过 pacman 命令安装</h1><p><code>pacman</code> 软件包管理器是 Arch Linux 的一大亮点。它将一个简单的 <code>二进制包格式</code>和易用的 <code>构建系统</code> 结合了起来。<code>pacman</code> 的目标是简化对软件包的管理，无论软件包是来自 <code>官方软件仓库</code> 还是 <code>用户自己创建</code>的软件包。</p>
<p>关于 <code>pacman</code> 命令的部分用法将在下面几节详细介绍。如果想查看更加完整的技术文档，可参考：<a target="_blank" rel="noopener" href="https://man.archlinux.org/man/pacman.8">ArchWiki—Pacman（英文完整版）</a>  ， <a target="_blank" rel="noopener" href="https://wiki.archlinuxcn.org/wiki/Pacman#%E5%AE%89%E8%A3%85%E8%BD%AF%E4%BB%B6%E5%8C%85">ArchWiki—Pacman（中文）</a>。</p>
<blockquote>
<p><strong>注</strong>：</p>
<p>pacman 软件包管理器拥有很强的管理能力。使用软件包而不是自己编译和安装程序有很多好处：</p>
<ul>
<li>轻松升级：pacman 会在更新可用时立即更新已安装的软件包</li>
<li>依赖检查：pacman 会为你处理依赖问题，只需要指明程序（名），<em>pacman</em> 就会将它和它所需的所有其他程序都一起安装。</li>
<li>干净卸载：pacman 持有软件包包含的所有文件的列表。这样一来，当你决定移除软件包时，不会无意留下任何文件。</li>
</ul>
</blockquote>
<h2 id="1-1-安装软件包"><a href="#1-1-安装软件包" class="headerlink" title="1.1 安装软件包"></a>1.1 安装软件包</h2><p>一个软件包就是一个归档包，其中包含：</p>
<ul>
<li>该软件所有（编译好的）文件，并按照每个文件的安装位置储存在一个与根目录结构相同的目录中；</li>
<li>该软件的元数据，如软件名称、版本和依赖等；</li>
<li>供 pacman 使用的其它描述性文件；</li>
<li>（可选）在安装、升级、卸载时执行的安装脚本。</li>
</ul>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">------------------------------------------------------------------------------ <span class="comment">#</span></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">下载软件包但不安装</span></span><br><span class="line">pacman -Sw &lt;包名&gt;</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">安装「单个」或者「一系列」软件包（含依赖）</span></span><br><span class="line">pacman -S &lt;包名&gt;			# 安装单个软件包</span><br><span class="line">pacman -S &lt;包名1 包名2 ...&gt;	 # 安装一系列软件包</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">通过正则表达式安装「一系列」软件包</span></span><br><span class="line">pacman -S $(pacman -Ssq 包正则表达式)</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">------------------------------------------------------------------------------ <span class="comment">#</span></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">存放在不同仓库的多版本软件需要在软件包前指定仓库名</span></span><br><span class="line">pacman -S &lt;仓库名/包名&gt;</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">------------------------------------------------------------------------------ <span class="comment">#</span></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">安装多个相似名称的软件包，用花括号扩展，举例：</span></span><br><span class="line">pacman -S plasma-&#123;desktop,mediacenter,nm&#125;</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">多个相似名称的软件包可以多层扩展，举例：</span></span><br><span class="line">pacman -S plasma-&#123;workspace&#123;,-wallpapers&#125;,pa&#125;</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">------------------------------------------------------------------------------ <span class="comment">#</span></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">安装包组，会提示选择安装包组中需要安装的包</span></span><br><span class="line">pacman -S &lt;包组名&gt;</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">查询安包组内的包含的具体软件名</span></span><br><span class="line">pacman -Sg &lt;包组名&gt;</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">------------------------------------------------------------------------------ <span class="comment">#</span></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">从本地安装软件包（不从源中获取）</span></span><br><span class="line">pacman -U /path/to/package/package_name-version.pkg.tar.zst</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">从远程安装软件包（从源或者指定链接中获取）</span></span><br><span class="line">pacman -U http://www.example.com/repo/example.pkg.tar.zst</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">将本地包保存至缓存</span></span><br><span class="line">pacman -U file:///path/to/package/package_name-version.pkg.tar.zst</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">------------------------------------------------------------------------------ <span class="comment">#</span></span></span><br></pre></td></tr></table></figure>



<h2 id="1-2-删除软件包"><a href="#1-2-删除软件包" class="headerlink" title="1.2 删除软件包"></a>1.2 删除软件包</h2><p><code>pacman</code> 命令的删除指令如下所示：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">------------------------------------------------------------------------------ <span class="comment">#</span></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">删除单个软件包</span></span><br><span class="line">pacman -R &lt;包名&gt;</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">删除指定软件包，并删除未被其他已安装软件包使用的依赖</span></span><br><span class="line">pacman -Rs &lt;包名&gt;</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">-Rs命令在移除包含其他所需包的组时有时候会拒绝运行，可采用如下指令</span></span><br><span class="line">pacman -Rsu &lt;包名&gt;</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">删除软件包和依赖这个软件包的所有程序，「递归操作，谨慎使用」</span></span><br><span class="line">pacman -Rsc &lt;包名&gt;</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">------------------------------------------------------------------------------ <span class="comment">#</span></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">删除被其他软件包依赖的软件包，但是不删除依赖这个软件包的其他软件包：</span></span><br><span class="line">pacman -Rdd &lt;包名&gt;</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">------------------------------------------------------------------------------ <span class="comment">#</span></span></span><br></pre></td></tr></table></figure>



<h2 id="1-3-查询包数据库"><a href="#1-3-查询包数据库" class="headerlink" title="1.3 查询包数据库"></a>1.3 查询包数据库</h2><p>在 <code>pacman</code> 中，可使用 <code>-Q</code> 参数查询本地软件包数据库， <code>-S</code> 查询同步数据库，以及 <code>-F</code>查询文件数据库。</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">------------------------------------------------------------------------------ <span class="comment">#</span></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">显示软件包的依赖树，「这一命令依赖于 pacman-contrib 包」</span></span><br><span class="line">pactree &lt;package_name&gt;</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">------------------------------------------------------------------------------ <span class="comment">#</span></span></span><br><span class="line">pacman -Q --help	#本地软件包数据库的帮助文档</span><br><span class="line">pacman -S --help	#同步数据库的帮助文档</span><br><span class="line">pacman -F --help	#文件数据库的帮助文档</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">------------------------------------------------------------------------------ <span class="comment">#</span></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">1.本地软件包数据库</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">在本地软件包数据库中查询匹配「单个」或者「多个」字符串的软件包</span></span><br><span class="line">pacman -Qs &lt;string&gt;				 # 匹配单个字符串</span><br><span class="line">pacman -Qs &lt;string1 string2 ...&gt;	# 匹配多个字符串</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">在本地软件包数据库中查询指定软件包的详细信息</span></span><br><span class="line">pacman -Qi &lt;package_name&gt;</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">在本地软件包数据库中查询指定软件包所包含文件的列表</span></span><br><span class="line">pacman -Ql &lt;package_name&gt;</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">------------------------------------------------------------------------------ <span class="comment">#</span></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">2.同步数据库</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">在同步数据库中查询匹配「单个」或者「多个」字符串的软件包</span></span><br><span class="line">pacman -Ss &lt;string&gt;				 # 匹配单个字符串</span><br><span class="line">pacman -Ss &lt;string1 string2 ...&gt;	# 匹配多个字符串</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">在同步数据库中获取指定软件的详细信息</span></span><br><span class="line">pacman -Si &lt;package_name&gt;       </span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">------------------------------------------------------------------------------ <span class="comment">#</span></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">3.文件数据库</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">在文件数据库中按文件名查找「单个」或者「一系列」文件</span></span><br><span class="line">pacman -F &lt;string&gt;				 # 单个文件</span><br><span class="line">pacman -F &lt;string1 string2 ...&gt;		# 一系列文件</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">查询远程库中软件包包含的文件</span></span><br><span class="line">pacman -Fl &lt;package_name&gt;</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">------------------------------------------------------------------------------ <span class="comment">#</span></span></span><br></pre></td></tr></table></figure>



<h2 id="1-4-清除包缓存"><a href="#1-4-清除包缓存" class="headerlink" title="1.4 清除包缓存"></a>1.4 清除包缓存</h2><p><code>pacman</code> 命令下载的软件包保存在 <code>/var/cache/pacman/pkg/</code> 路径中，并且它不会自动移除旧的和未安装版本的软件包。</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">------------------------------------------------------------------------------ <span class="comment">#</span></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">启用 和 启动 paccache.timer 每周删除不使用的包</span></span><br><span class="line">paccache -r</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">设置保留最近几个版本的软件数量</span></span><br><span class="line">paccache -rk1</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">------------------------------------------------------------------------------ <span class="comment">#</span></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">删除目前没有安装的所有缓存的包，和没有被使用的同步数据库</span></span><br><span class="line">pacman -Sc</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">删除缓存中的全部文件（两个c强制删除）</span></span><br><span class="line">pacman -Scc</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">------------------------------------------------------------------------------ <span class="comment">#</span></span></span><br></pre></td></tr></table></figure>



<h2 id="1-5-其他命令"><a href="#1-5-其他命令" class="headerlink" title="1.5 其他命令"></a>1.5 其他命令</h2><p>除了上面几节介绍的命令之外，还有一些 <code>pacman</code> 相关的零碎指令如下所示：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">------------------------------------------------------------------------------ <span class="comment">#</span></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">升级整个系统，y 是更新数据库，yy 是强制更新数据库，u 是升级软件</span></span><br><span class="line">pacman -Syyu</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">------------------------------------------------------------------------------ <span class="comment">#</span></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">升级系统时安装「单个」或者「一系列」软件包</span></span><br><span class="line">pacman -Syu &lt;包名&gt;			#「单个」软件包</span><br><span class="line">pacman -Syu &lt;包名1 包名2 ...&gt;	 #「一系列」软件包</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">------------------------------------------------------------------------------ <span class="comment">#</span></span></span><br></pre></td></tr></table></figure>



<h1 id="二-通过-yay-命令安装"><a href="#二-通过-yay-命令安装" class="headerlink" title="二.通过 yay 命令安装"></a>二.通过 yay 命令安装</h1><p>yay 命令是一个 Arch Linux 系统的命令行软件。在使用此命令安装软件时需要确保在 <code>/etc/pacman.conf</code> 文件中正确配置了 Arch 源。yay 是 AUR 助手的其中一种，与其他的 AUR 助手的对比可以参考：<a target="_blank" rel="noopener" href="https://wiki.archlinuxcn.org/wiki/AUR_%E5%8A%A9%E6%89%8B">ArchWiki—AUR 助手</a></p>
<p>使用 yay 这类 AUR 助手的好处是：</p>
<ol>
<li>自动解决软件<strong>包间依赖关系</strong>；</li>
<li>动态地<strong>搜索</strong>、<strong>编译</strong>和<strong>构建</strong>包；</li>
<li>安装与管理 AUR 中的包。</li>
</ol>
<blockquote>
<p><strong>注</strong>：</p>
<ol>
<li>要想使用 yay 命令行软件，需要确保安装了 <code>base-devel</code> 包和 <code>git</code> 包，然后再安装 yay 命令。如果没有安装，可参考如下命令安装：</li>
</ol>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">加入 `--needed` 参数不会重新安装已经安装的软件包</span></span><br><span class="line">sudo pacman -S --needed base-devel git</span><br></pre></td></tr></table></figure>

<ol start="2">
<li>值得注意的是， <code>yay</code> 命令可以从 AUR 上获取软件并安装，也可以从官方源获取软件包再安装。</li>
</ol>
</blockquote>
<p><code>yay</code> 使用与 <code>pacman</code> 相类似的命令结构。因此本节下面部分将展示 yay 的部分指令用法，更加详细的可参阅：<a target="_blank" rel="noopener" href="https://wiki.archlinuxcn.org/wiki/Yay">ArchWiki—Yay</a>。</p>
<h2 id="2-1-安装软件包"><a href="#2-1-安装软件包" class="headerlink" title="2.1 安装软件包"></a>2.1 安装软件包</h2><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">------------------------------------------------------------------------------ <span class="comment">#</span></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">在 AUR 上搜索包名</span></span><br><span class="line">yay &lt;AUR包名&gt;</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">下载软件包但不安装</span></span><br><span class="line">yay -G &lt;AUR包名&gt;</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">------------------------------------------------------------------------------ <span class="comment">#</span></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">安装「单个」或者「一系列」软件包（含依赖）</span></span><br><span class="line">yay -S &lt;AUR包名&gt;				       # 安装单个软件包</span><br><span class="line">yay -S &lt;AUR包名1 AUR包名2 ...&gt;		# 安装一系列软件包</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">通过正则表达式安装「一系列」软件包</span></span><br><span class="line">yay -S $(pacman -Ssq AUR包正则表达式)</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">------------------------------------------------------------------------------ <span class="comment">#</span></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">存放在不同仓库的多版本软件需要在软件包前指定仓库名</span></span><br><span class="line">yay -S &lt;仓库名/AUR包名&gt;</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">------------------------------------------------------------------------------ <span class="comment">#</span></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">安装包组，会提示选择安装包组中需要安装的包</span></span><br><span class="line">yay -S &lt;包组名&gt;</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">查询安装包组内包含的具体软件名</span></span><br><span class="line">yay -Sg &lt;包组名&gt;</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">------------------------------------------------------------------------------ <span class="comment">#</span></span></span><br></pre></td></tr></table></figure>



<h2 id="2-2-删除软件包"><a href="#2-2-删除软件包" class="headerlink" title="2.2 删除软件包"></a>2.2 删除软件包</h2><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">------------------------------------------------------------------------------ <span class="comment">#</span></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">删除软件包</span></span><br><span class="line">yay -R &lt;AUR包名&gt;</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">删除指定软件包，并删除未被其他已安装软件包使用的依赖</span></span><br><span class="line">yay -Rs &lt;AUR包名&gt;</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">-Rs命令在移除包含其他所需包的组时有时候会拒绝运行，可采用如下指令</span></span><br><span class="line">yay -Rsu &lt;AUR包名&gt;</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">删除包及其依赖项</span></span><br><span class="line">yay -Rns &lt;AUR包名&gt;</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">删除软件包和依赖这个软件包的所有程序，「递归操作，谨慎使用」</span></span><br><span class="line">yay -Rsc &lt;AUR包名&gt;</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">删除被其他软件包依赖的软件包，但是不删除依赖这个软件包的其他软件包：</span></span><br><span class="line">yay -Rdd &lt;AUR包名&gt;</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">------------------------------------------------------------------------------ <span class="comment">#</span></span></span><br></pre></td></tr></table></figure>



<h2 id="2-3-查询包数据库"><a href="#2-3-查询包数据库" class="headerlink" title="2.3 查询包数据库"></a>2.3 查询包数据库</h2><p>在 <code>yay</code> 中，可使用 <code>-Q</code> 参数查询本地软件包数据库， <code>-S</code> 查询同步数据库，以及 <code>-F</code>查询文件数据库。</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">------------------------------------------------------------------------------ <span class="comment">#</span></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">1.本地软件包数据库</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">在本地软件包数据库中查询匹配「单个」或者「多个」字符串的软件包</span></span><br><span class="line">yay -Qs &lt;string&gt;		        # 匹配单个字符串</span><br><span class="line">yay -Qs &lt;string1 string2 ...&gt;	# 匹配多个字符串</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">在本地软件包数据库中查询指定软件包的详细信息</span></span><br><span class="line">yay -Qi &lt;package_name&gt;</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">在本地软件包数据库中查询指定软件包所包含文件的列表</span></span><br><span class="line">yay -Ql &lt;package_name&gt;</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">------------------------------------------------------------------------------ <span class="comment">#</span></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">2.同步数据库</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">在同步数据库中查询匹配「单个」或者「多个」字符串的软件包</span></span><br><span class="line">yay -Ss &lt;string&gt;				 # 匹配单个字符串</span><br><span class="line">yay -Ss &lt;string1 string2 ...&gt;	# 匹配多个字符串</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">在同步数据库中获取指定软件的详细信息</span></span><br><span class="line">yay -Si &lt;package_name&gt;       </span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">------------------------------------------------------------------------------ <span class="comment">#</span></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">3.文件数据库</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">在文件数据库中按文件名查找「单个」或者「一系列」文件</span></span><br><span class="line">yay -F &lt;string&gt;				 # 单个文件</span><br><span class="line">yay -F &lt;string1 string2 ...&gt;	# 一系列文件</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">查询远程库中软件包包含的文件</span></span><br><span class="line">yay -Fl &lt;package_name&gt;</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">------------------------------------------------------------------------------ <span class="comment">#</span></span></span><br></pre></td></tr></table></figure>



<h2 id="2-4-清除包缓存"><a href="#2-4-清除包缓存" class="headerlink" title="2.4 清除包缓存"></a>2.4 清除包缓存</h2><p><code>yay</code> 常用的清除缓存指令如下：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">------------------------------------------------------------------------------ <span class="comment">#</span></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">删除目前没有安装的所有缓存的包，和没有被使用的同步数据库</span></span><br><span class="line">yay -Sc</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">删除缓存中的全部文件（两个c强制删除）</span></span><br><span class="line">yay -Scc</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">------------------------------------------------------------------------------ <span class="comment">#</span></span></span><br></pre></td></tr></table></figure>



<h2 id="2-5-其他命令"><a href="#2-5-其他命令" class="headerlink" title="2.5 其他命令"></a>2.5 其他命令</h2><p>除了上面几节介绍的命令之外，还有一些 <code>yay</code> 相关的零碎指令如下所示：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">------------------------------------------------------------------------------ <span class="comment">#</span></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">其他命令</span> </span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">升级整个系统，y 是更新数据库，yy 是强制更新数据库，u 是升级软件</span></span><br><span class="line">yay -Syyu	# 仅输入 yay 则等效于 yay -Syu</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">仅升级 AUR 包</span></span><br><span class="line">yay -Sua</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">------------------------------------------------------------------------------ <span class="comment">#</span></span></span><br></pre></td></tr></table></figure>



<h2 id="2-6-常用指令汇总"><a href="#2-6-常用指令汇总" class="headerlink" title="2.6 常用指令汇总"></a>2.6 常用指令汇总</h2><p>更加详细的指令信息如下图所示：</p>
<table>
<thead>
<tr>
<th align="center">命令</th>
<th align="center">描述</th>
</tr>
</thead>
<tbody><tr>
<td align="center">yay</td>
<td align="center">升级系统，相当于 yay -Syu</td>
</tr>
<tr>
<td align="center">yay <Search Term></td>
<td align="center">显示包安装选择菜单</td>
</tr>
<tr>
<td align="center">yay -Bi <folder></td>
<td align="center">安装依赖并构建本地 PKGBUILD</td>
</tr>
<tr>
<td align="center">yay -G <AUR Package></td>
<td align="center">从 ABS 或 AUR 下载 PKGBUILD (yay v12.0以上版本)</td>
</tr>
<tr>
<td align="center">yay -Gp <AUR Package></td>
<td align="center">打印 ABS 或 AUR 的 PKGBUILD 到 stdout</td>
</tr>
<tr>
<td align="center">yay -Ps</td>
<td align="center">打印系统统计信息</td>
</tr>
<tr>
<td align="center">yay -Syu –devel</td>
<td align="center">执行系统升级，但同时检查开发包的更新</td>
</tr>
<tr>
<td align="center">yay -Syu –timeupdate</td>
<td align="center">执行系统升级并使用PKGBUILD修改时间（不是版本号）来确定更新</td>
</tr>
<tr>
<td align="center">yay -Wu <AUR Package Name></td>
<td align="center">取消对包的投票 (需要设置 AUR_USERNAME 和 AUR_PASSWORD 环境变量) (yay v11.3以上版本)</td>
</tr>
<tr>
<td align="center">yay -Wv <AUR Package Name></td>
<td align="center">投票支持包 (需要设置 AUR_USERNAME 和 AUR_PASSWORD 环境变量) (yay v11.3以上版本)</td>
</tr>
<tr>
<td align="center">yay -Y –combinedupgrade –save</td>
<td align="center">使组合升级成为默认模式</td>
</tr>
<tr>
<td align="center">yay -Y –gendb</td>
<td align="center">生成用于开发更新的开发包数据库</td>
</tr>
<tr>
<td align="center">yay -Yc</td>
<td align="center">清理不需要的依赖</td>
</tr>
</tbody></table>
<blockquote>
<p><strong>注</strong>：</p>
<p>如果方便，也可在命令行中键入 <code>yay --help</code> 或者是 <code>yay -h</code> 指令查看 yay 命令的用法。</p>
</blockquote>
<h1 id="三-通过-AUR-安装"><a href="#三-通过-AUR-安装" class="headerlink" title="三.通过 AUR 安装"></a>三.通过 AUR 安装</h1><p>AUR 全称 Archlinux User-community Repository，即 Archlinux 用户社区的软件库。具体的介绍可以参考：<a target="_blank" rel="noopener" href="https://wiki.archlinuxcn.org/wiki/Arch_%E7%94%A8%E6%88%B7%E8%BD%AF%E4%BB%B6%E4%BB%93%E5%BA%93_(AUR)">ArchWiki—AUR</a> 。AUR 是为用户而建，并由用户主导的 Arch 软件仓库。AUR 中的软件包以软件包生成脚本（PKGBUILD）的形式提供，用户自己通过 makepkg 生成软件包，再由 pacman 安装软件包。</p>
<p>Archlinux 的灵魂是 PKGBUILD、 <a target="_blank" rel="noopener" href="https://wiki.archlinuxcn.org/wiki/Arch_%E7%94%A8%E6%88%B7%E8%BD%AF%E4%BB%B6%E4%BB%93%E5%BA%93_(AUR)">AUR</a>  和 <a target="_blank" rel="noopener" href="https://wiki.archlinuxcn.org/wiki/Arch_%E6%9E%84%E5%BB%BA%E7%B3%BB%E7%BB%9F">ABS</a>  ，在 AUR 仓库能查到的软件包，都可以使用上述的方法进行安装。为了演示这一方法的可行性，这里以 <code>WingIDE</code> 软件的安装为例演示安装流程：</p>
<ol>
<li>首先，去到 <a target="_blank" rel="noopener" href="https://aur.archlinux.org/">AUR</a> 官方网站并在 <code>Package Search</code> 栏目搜索软件包（WingIDE）</li>
</ol>
<div style="text-align: center;">
    <img src="https://dustwind-picture-upload.oss-cn-chengdu.aliyuncs.com/img/Manjaro%20Install/%E8%BD%AF%E4%BB%B6%E5%AE%89%E8%A3%85%E6%96%B9%E6%B3%95/3.1AUR%E5%AE%98%E7%BD%91.png" alt="AUR官方网站"  />
</div>



<ol start="2">
<li>搜索软件包会跳转到搜索结果页，在这一页面可能会有许多相关的软件，选择自己需要的软件点击查看详情即可</li>
</ol>
<div style="text-align: center;">
    <img src="https://dustwind-picture-upload.oss-cn-chengdu.aliyuncs.com/img/Manjaro%20Install/%E8%BD%AF%E4%BB%B6%E5%AE%89%E8%A3%85%E6%96%B9%E6%B3%95/3.2.%E5%9C%A8AUR%E4%B8%AD%E6%90%9C%E7%B4%A2%E8%BD%AF%E4%BB%B6%E5%8C%85.png" alt="在AUR中搜索软件包"  />
</div>



<ol start="3">
<li>进入软件详情页会有许多具体信息，通过 AUR 社区安装软件需要复制对应软件的 <code>Git Clone URL</code></li>
</ol>
<div style="text-align: center;">
    <img src="https://dustwind-picture-upload.oss-cn-chengdu.aliyuncs.com/img/Manjaro%20Install/%E8%BD%AF%E4%BB%B6%E5%AE%89%E8%A3%85%E6%96%B9%E6%B3%95/3.3.AUR%E6%A3%80%E7%B4%A2%E8%BD%AF%E4%BB%B6%E7%9A%84%E8%AF%A6%E7%BB%86%E4%BF%A1%E6%81%AF.png" alt="检索软件包详细信息"  />
</div>



<ol start="4">
<li>获取到软件的 <code>Git Clone URL</code> 后在终端中输入 <code>git clone &lt;Git Clone URL&gt;</code> 将软件包克隆至本地</li>
</ol>
<div style="text-align: center;">
    <img src="https://dustwind-picture-upload.oss-cn-chengdu.aliyuncs.com/img/Manjaro%20Install/%E8%BD%AF%E4%BB%B6%E5%AE%89%E8%A3%85%E6%96%B9%E6%B3%95/3.4.%E5%88%A9%E7%94%A8git%E5%85%8B%E9%9A%86%E8%87%B3%E6%9C%AC%E5%9C%B0.png" alt="git克隆软件包"  />
</div>



<ol start="5">
<li>紧接着，进入到克隆下来的软件包文件夹，使用 <code>makepkg -s</code> 指令构建软件包</li>
</ol>
<div style="text-align: center;">
    <img src="https://dustwind-picture-upload.oss-cn-chengdu.aliyuncs.com/img/Manjaro%20Install/%E8%BD%AF%E4%BB%B6%E5%AE%89%E8%A3%85%E6%96%B9%E6%B3%95/3.5.%E6%9E%84%E5%BB%BA%E8%BD%AF%E4%BB%B6%E5%8C%85.png" alt="构建软件包"  />
</div>



<ol start="6">
<li>最后通过 <code>pacman</code> 命令的本地安装功能进行文件夹中的 <code>.pkg.tar.zst</code> 软件包安装</li>
</ol>
<div style="text-align: center;">
    <img src="https://dustwind-picture-upload.oss-cn-chengdu.aliyuncs.com/img/Manjaro%20Install/%E8%BD%AF%E4%BB%B6%E5%AE%89%E8%A3%85%E6%96%B9%E6%B3%95/3.6.%E6%9C%AC%E5%9C%B0%E5%AE%89%E8%A3%85.png" alt="本地安装"  />
</div>



<p>至此，通过 AUR 安装软件的介绍到此结束。</p>
<blockquote>
<p><strong>注</strong>：</p>
<ol>
<li>如果仅使用 <code>makepkg</code> 指令，可能会因为依赖包问题而报错，因此最好是使用 <code>makepkg -s</code>。</li>
<li>使用 <code>makepkg -s</code>命令会构建好软件包，但是安装还需要调用 <code>pacman -U &lt;Packge Name&gt;</code> 指令进行本地安装，因此可以换做 <code>makepkg -si</code> 指令在构建完后自动安装软件包。</li>
</ol>
</blockquote>
<h1 id="四-通过转换-deb-包安装"><a href="#四-通过转换-deb-包安装" class="headerlink" title="四.通过转换 deb 包安装"></a>四.通过转换 deb 包安装</h1><p>AUR 上储备了相当数量的软件，在上面能获取到日常使用的大部分软件。它虽然很好用了，但是一些无法编译的包（闭源代码软件包），或是在 AUR 上生成报错的软件包则还是需要另外的途径编译构建新的包。此时便可以通过本文所述的这一粗糙的方法将 deb 包转换成 archlinux 包。</p>
<h2 id="4-1-debtap-软件部署"><a href="#4-1-debtap-软件部署" class="headerlink" title="4.1 debtap 软件部署"></a>4.1 debtap 软件部署</h2><h3 id="4-1-1-安装-debtap"><a href="#4-1-1-安装-debtap" class="headerlink" title="4.1.1 安装 debtap"></a>4.1.1 安装 debtap</h3><ol>
<li>想要在 Manjaro 系统上转换 deb 格式的包，需要的就是先安装 debtap 软件。可使用如下命令安装 debtap 软件：</li>
</ol>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">yay -S debtap</span><br></pre></td></tr></table></figure>



<div style="text-align: center;">
    <img src="https://dustwind-picture-upload.oss-cn-chengdu.aliyuncs.com/img/Manjaro%20Install/%E8%BD%AF%E4%BB%B6%E5%AE%89%E8%A3%85%E6%96%B9%E6%B3%95/4.1.%E5%AE%89%E8%A3%85debtap%E8%BD%AF%E4%BB%B6%EF%BC%88%E5%BC%80%E5%A7%8B%EF%BC%89.png" alt="安装debtap"  />
</div>



<ol start="2">
<li>在安装完 debtap 软件之后，这里相当建议更新一次 debtap 的源以创建或者更新 pkgfile 和 debtap 数据库。这里可以通过如下命令更新 debtap 的源：</li>
</ol>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo debtap -u</span><br></pre></td></tr></table></figure>

<p>示例结果如下图所示：</p>
<div style="text-align: center;">
    <img src="https://dustwind-picture-upload.oss-cn-chengdu.aliyuncs.com/img/Manjaro%20Install/%E8%BD%AF%E4%BB%B6%E5%AE%89%E8%A3%85%E6%96%B9%E6%B3%95/4.2.%E6%9B%B4%E6%96%B0debtap%E6%BA%90.png" alt="更新debtap源"  />
</div>

<blockquote>
<p><strong>注</strong>：</p>
<p>这条指令在安装完 debtap 软件之后至少需要运行一次，否则调用 debtap 软件时可能会报错。</p>
</blockquote>
<h3 id="4-1-2-debtap-换源"><a href="#4-1-2-debtap-换源" class="headerlink" title="4.1.2 debtap 换源"></a>4.1.2 debtap 换源</h3><p>值得注意的是 debtap 默认的官方源在大陆地区访问很卡，因此需要给 debtap 更换本地的镜像源。换源的方式也很简单，那就是修改 <code> /usr/bin/debtap</code> 配置文件。修改配置文件可以通过如下两种方式进行：</p>
<ol>
<li>一种是利用 vim 命令访问该配置文件，然后更改文件中的这两项内容：</li>
</ol>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">sudo vim /usr/bin/debtap</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">替换 http://ftp.debian.org/debian/dists 为 https://mirrors.ustc.edu.cn/debian/dists</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">替换 http://archive.ubuntu.com/ubuntu/dists 为 https://mirrors.ustc.edu.cn/ubuntu/dists/</span></span><br></pre></td></tr></table></figure>



<ol start="2">
<li>另外一种便更加简单粗暴，就是在命令行中直接将指定信息写入该配置文件。</li>
</ol>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">sudo sed -i &quot;s|http://ftp.debian.org/debian/dists|https://mirrors.ustc.edu.cn/debian/dists|g&quot; /usr/bin/debtap</span><br><span class="line">sudo sed -i &quot;s|http://archive.ubuntu.com/ubuntu/dists|https://mirrors.ustc.edu.cn/ubuntu/dists|g&quot; /usr/bin/debtap</span><br></pre></td></tr></table></figure>



<h2 id="4-2-安装-deb-包格式的软件"><a href="#4-2-安装-deb-包格式的软件" class="headerlink" title="4.2 安装 deb 包格式的软件"></a>4.2 安装 deb 包格式的软件</h2><p>在如下的示例中笔者都以 Typora 软件安装参考。debtap 命令的使用很简单</p>
<h3 id="4-2-1-转换格式"><a href="#4-2-1-转换格式" class="headerlink" title="4.2.1 转换格式"></a>4.2.1 转换格式</h3><p>直接对下载的 deb 软件包使用 debtap 命令即可转换包格式</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">debtap &lt;Deb Package Name&gt;</span><br></pre></td></tr></table></figure>

<p>转换包格式的参考示例执行结果如下图所示：</p>
<div style="text-align: center;">
    <img src="https://dustwind-picture-upload.oss-cn-chengdu.aliyuncs.com/img/Manjaro%20Install/%E8%BD%AF%E4%BB%B6%E5%AE%89%E8%A3%85%E6%96%B9%E6%B3%95/4.3.%E8%BD%AC%E6%8D%A2Typora%E8%BD%AF%E4%BB%B6%E7%9A%84deb%E5%8C%85%E6%A0%BC%E5%BC%8F.png" alt="deb包格式转换"  />
</div>



<p>在图中可以看到笔者有多个版本的 Typora 软件，这里转换格式的是 <code>1.8.9</code> 版本的 Typora 软件。同时上图也展示出出了转换后软件包格式类型为： <code>.pkg.tar.zst</code>。</p>
<blockquote>
<p><strong>注</strong>：</p>
<ol>
<li>在包转化的过程中，你不想回答任何问题，使用 <code>-q</code> 略过除了编辑元数据之外的所有问题。当然，也可使用 <code>-Q</code> 略过所有问题。命令的格式如下所示：</li>
</ol>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">略过除了编辑元数据之外的所有问题</span></span><br><span class="line">debtap -q &lt;Deb Package Name&gt;</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">略过所有问题</span></span><br><span class="line">debtap -Q &lt;Deb Package Name&gt;</span><br></pre></td></tr></table></figure>



<ol start="2">
<li>如果想要查看 debtap 的帮助文档，可执行如下命令获取：</li>
</ol>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">debtap -h</span><br></pre></td></tr></table></figure>

<p>运行的参考示例如下图所示：</p>
<div style="text-align: center;">
    <img src="https://dustwind-picture-upload.oss-cn-chengdu.aliyuncs.com/img/Manjaro%20Install/%E8%BD%AF%E4%BB%B6%E5%AE%89%E8%A3%85%E6%96%B9%E6%B3%95/4.4.%E6%9F%A5%E7%9C%8Bdebtap%E5%91%BD%E4%BB%A4%E5%8F%82%E8%80%83%E6%96%87%E6%A1%A3.png" alt="查看debtap的帮助文档"  />
</div>


</blockquote>
<h3 id="4-2-2-本地安装"><a href="#4-2-2-本地安装" class="headerlink" title="4.2.2 本地安装"></a>4.2.2 本地安装</h3><p>将 deb 包转换成 ArchLinux 系统格式的软件包后便可以本地安装了。可以通过如下命令安装</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo pacman -U &lt;Packge Name&gt;</span><br></pre></td></tr></table></figure>

<p>安装软件的参考示例执行结果如下图所示：</p>
<div style="text-align: center;">
    <img src="https://dustwind-picture-upload.oss-cn-chengdu.aliyuncs.com/img/Manjaro%20Install/%E8%BD%AF%E4%BB%B6%E5%AE%89%E8%A3%85%E6%96%B9%E6%B3%95/4.5.%E6%9C%AC%E5%9C%B0%E5%AE%89%E8%A3%85%E8%BD%AC%E6%8D%A2%E5%90%8E%E7%9A%84%E8%BD%AF%E4%BB%B6%E5%8C%85.png" alt="本地安装软件包"  />
</div>



<p>笔者之前已经安装过 Typora 软件，因此看到上面提示重新安装。至此，已成功本地安装转换后的软件包。</p>
<h1 id="五-通过-AppImage-包安装"><a href="#五-通过-AppImage-包安装" class="headerlink" title="五.通过 AppImage 包安装"></a>五.通过 AppImage 包安装</h1><p>这种方式是在打包程序时就将所需的库以及依赖通过打包到 AppImage 文件中再发布，此种方式的好处是这种安装包可以在任意发行版 Linux 系统中运行而无需另外安装应用。更具体内容可参照 <a target="_blank" rel="noopener" href="https://appimage.org/">AppImage官网</a> 描述。</p>
<h2 id="5-1-技术特点"><a href="#5-1-技术特点" class="headerlink" title="5.1 技术特点"></a>5.1 技术特点</h2><ol>
<li><strong>简单</strong>：AppImage 核心思想即：<code>一个文件就是一个应用程序</code>，就是说每个 AppImage 文件都包含应用程序以及应用程序运行所需的所有文件。换言之，除了操作系统本身的基础组件，Appimage不需要依赖包即可运行</li>
<li><strong>可靠</strong>：AppImage 格式是<code>上游应用打包</code>的理想选择，这意味着可以直接从开发者那里获取软件，而不需要任何中间步骤。</li>
<li><strong>快速</strong>：AppImage应用可以直接下载并且运行，无需安装，并且不需要root权限。</li>
</ol>
<h2 id="5-2-命令行实现"><a href="#5-2-命令行实现" class="headerlink" title="5.2 命令行实现"></a>5.2 命令行实现</h2><p>运行 AppImage 文件非常简单，下载后，通过以下步骤即可运行程序：</p>
<ol>
<li>下载需要的 AppImage 软件到运行文件夹，例如：<code>/path/to/AppImage</code></li>
<li>打开当前发行版 Linux 系统终端（Terminal）</li>
<li>进入 AppImage 文件所在目录，例如：<code>cd /path/to/AppImage</code></li>
<li>给需要运行的 AppImage 文件赋予相应的权限，例如：<code>sudo chmod a+x my.AppImage</code></li>
<li>这样便可以运行 AppImage 软件了，例如：<code>./my.AppImage</code></li>
</ol>
<p>这里在代码行中做个汇总：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">进入文件目录</span></span><br><span class="line">cd /path/to/AppImage	</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">查看目录中文件</span></span><br><span class="line">ls -l				     </span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">更改文件权限</span></span><br><span class="line">sudo chmod a+x my.AppImage</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">运行程序</span></span><br><span class="line">./my.AppImage</span><br></pre></td></tr></table></figure>

<p>笔者在本人系统中运行如下图所示：</p>
<div style="text-align: center;">
    <img src="https://dustwind-picture-upload.oss-cn-chengdu.aliyuncs.com/img/Manjaro%20Install/%E8%BD%AF%E4%BB%B6%E5%AE%89%E8%A3%85%E6%96%B9%E6%B3%95/5.1.%E9%80%9A%E8%BF%87%E5%91%BD%E4%BB%A4%E8%A1%8C%E8%BF%90%E8%A1%8CAppImage%E7%A8%8B%E5%BA%8F.png" alt="命令行安装AppImage软件"  />
</div>


<h2 id="5-2-沙盒实现"><a href="#5-2-沙盒实现" class="headerlink" title="5.2 沙盒实现"></a>5.2 沙盒实现</h2><p>通过命令行操作可能很繁琐，那么可以通过诸如 AppImageLauncher 的沙盒程序来整合 AppImage 程序。下面将阐述利用沙盒程序整合 AppImage 文件的步骤：</p>
<ol>
<li>首先在当前发行版 Linux 系统中安装沙盒程序，笔者使用的是 AppImageLauncher 程序。</li>
</ol>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">yay -S AppImageLauncher</span><br></pre></td></tr></table></figure>



<div style="text-align: center;">
    <img src="https://dustwind-picture-upload.oss-cn-chengdu.aliyuncs.com/img/Manjaro%20Install/%E8%BD%AF%E4%BB%B6%E5%AE%89%E8%A3%85%E6%96%B9%E6%B3%95/5.2.%E5%AE%89%E8%A3%85AppImageLauncher%E8%BD%AF%E4%BB%B6.png" alt="沙盒软件安装AppImage软件"  />
</div>



<ol start="2">
<li>然后下载需要运行的 AppImage 文件。</li>
<li>通过文件资源管理器进入 AppImage 所在目录，然后点击运行该 AppImage 文件。</li>
</ol>
<div style="text-align: center; margin: 35px;">
    <img src="https://dustwind-picture-upload.oss-cn-chengdu.aliyuncs.com/img/Manjaro%20Install/%E8%BD%AF%E4%BB%B6%E5%AE%89%E8%A3%85%E6%96%B9%E6%B3%95/5.3.%E5%8F%8C%E5%87%BB%E6%89%A7%E8%A1%8CAppImage%E8%BD%AF%E4%BB%B6.png" alt="双击安装AppImage软件"  />
</div>


<p>至此，AppImageLauncher 就将 AppImage 文件整合到对应的目录统一管理。并且在整合的过程中在开始菜单自动生成了访问图标。</p>

      

      
    </div>
    <div class="article-info article-info-index">
      
      
	<div class="article-tag tagcloud">
		<i class="icon-price-tags icon"></i>
		<ul class="article-tag-list">
			 
        		<li class="article-tag-list-item">
        			<a href="javascript:void(0)" class="js-tag article-tag-list-link color1">Linux</a>
        		</li>
      		 
        		<li class="article-tag-list-item">
        			<a href="javascript:void(0)" class="js-tag article-tag-list-link color3">Manjaro</a>
        		</li>
      		
		</ul>
	</div>

      

      
        <p class="article-more-link">
          <a class="article-more-a" href="/2024/01/31/Manjaro%E7%9A%84%E8%BD%AF%E4%BB%B6%E5%AE%89%E8%A3%85%E6%96%B9%E5%BC%8F/">展开全文 >></a>
        </p>
      

      
      <div class="clearfix"></div>
    </div>
  </div>
</article>

<aside class="wrap-side-operation">
    <div class="mod-side-operation">
        
        <div class="jump-container" id="js-jump-container" style="display:none;">
            <a href="javascript:void(0)" class="mod-side-operation__jump-to-top">
                <i class="icon-font icon-back"></i>
            </a>
            <div id="js-jump-plan-container" class="jump-plan-container" style="top: -11px;">
                <i class="icon-font icon-plane jump-plane"></i>
            </div>
        </div>
        
        
    </div>
</aside>




  
    <article id="post-Manjaro使用常见问题汇总" class="article article-type-post  article-index" itemscope itemprop="blogPost">
  <div class="article-inner">
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/2024/01/31/Manjaro%E4%BD%BF%E7%94%A8%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98%E6%B1%87%E6%80%BB/">Manjaro/Linux使用常见问题</a>
    </h1>
  

        
        <a href="/2024/01/31/Manjaro%E4%BD%BF%E7%94%A8%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98%E6%B1%87%E6%80%BB/" class="archive-article-date">
  	<time datetime="2024-01-31T12:01:21.000Z" itemprop="datePublished"><i class="icon-calendar icon"></i>2024-01-31</time>
</a>
        
      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <h1 id="一-双系统时区问题"><a href="#一-双系统时区问题" class="headerlink" title="一.双系统时区问题"></a>一.双系统时区问题</h1><h2 id="1-1-问题描述"><a href="#1-1-问题描述" class="headerlink" title="1.1 问题描述"></a>1.1 问题描述</h2><p>当安装了 Windows 和 Manjaro 双系统后，发现出现了 Windows 系统时间比 Manjaro 系统时间慢 8 小时的情况。</p>
<h2 id="1-2-问题分析"><a href="#1-2-问题分析" class="headerlink" title="1.2 问题分析"></a>1.2 问题分析</h2><p>在电脑中会有两个时间，一个是硬件时间，一个是系统时间。</p>
<ol>
<li>硬件时间：这个时间信息存储在电脑主板中，因此没有夏令时以及时区等概念。</li>
<li>系统时间：这个时间信息由系统管理，通常是通过网络时间同步（Network Time Synchronization，NTS），有夏令时以及时区等概念。</li>
</ol>
<blockquote>
<p><strong>注</strong>：</p>
<p>系统时间提供了两种管理思路：</p>
<ul>
<li>localtime：本地时间，Windows 系统采用此种方法。</li>
<li>UTC：世界标准时间，在众多 Linux 系统中广泛使用。这种方法只需将 UTC 时间加减时区便得到本地时间。</li>
</ul>
</blockquote>
<p>Linux 认为硬件时间是 UTC 标准时间，Linux 时间同步后会把“正确”的时间做减 8 操作作为标准 UTC 标准时间写入主板。</p>
<p>Windows 系统会认为硬件时间就是本地时间，所以直接把主板中的时间信息拿来当做当前的时间。设置或同步时间后也会把“正确”时间写入主板。</p>
<p>这样操作就会出现双系统时间不同步的情况。</p>
<h2 id="1-3-解决方法"><a href="#1-3-解决方法" class="headerlink" title="1.3 解决方法"></a>1.3 解决方法</h2><p>解决的思路就是让 Manjaro 系统使用 localtime 或者让 Windows 系统使用 UTC 时间。具体操作是：</p>
<ol>
<li>在 Manjaro 系统中设置本地时间</li>
</ol>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">使用timedatectl可以查询时间信息，通过如下方式设置 Manjaro 本地时间</span></span><br><span class="line">sudo timedatectl set-local-rtc true</span><br></pre></td></tr></table></figure>



<ol start="2">
<li>在 Windows 系统中使用 UTC 时间</li>
</ol>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">以管理员身份使用运行</span></span><br><span class="line">reg add &quot;HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\TimeZoneInformation&quot; /v RealTimeIsUniversal /d 1 /t REG_DWORD /f</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">使用以上方法无效或系统为64位：</span></span><br><span class="line">reg add &quot;HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\TimeZoneInformation&quot; /v RealTimeIsUniversal /d 1 /t REG_QWORD /f</span><br></pre></td></tr></table></figure>



<blockquote>
<p><strong>注</strong>：</p>
<p>本问题参照 ArchLinux Wiki 关于时间问题的处理：<a target="_blank" rel="noopener" href="https://wiki.archlinux.org/title/System_time">ArchLinux Wiki —- Time</a></p>
</blockquote>
<h1 id="二-GitHub-443错误"><a href="#二-GitHub-443错误" class="headerlink" title="二.GitHub 443错误"></a>二.GitHub 443错误</h1><h2 id="2-1问题描述"><a href="#2-1问题描述" class="headerlink" title="2.1问题描述"></a>2.1问题描述</h2><p>当从Git远程仓库 pull、push 或者 clone 时会出现如下错误：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">Failed to connect to github.com port 443: Connection refused</span><br></pre></td></tr></table></figure>



<h2 id="2-2-解决方法"><a href="#2-2-解决方法" class="headerlink" title="2.2 解决方法"></a>2.2 解决方法</h2><h3 id="2-2-1-由代理引起"><a href="#2-2-1-由代理引起" class="headerlink" title="2.2.1 由代理引起"></a>2.2.1 由代理引起</h3><ol>
<li>若是由于<strong>代理</strong>引起的，则使用如下命令关闭代理：</li>
</ol>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">git config --global --unset http.proxy</span><br><span class="line">git config --global --unset https.proxy</span><br></pre></td></tr></table></figure>

<blockquote>
<p><strong>注</strong>：</p>
<p>重新开启 git 全局代理的方法：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">添加全局代理：</span><br><span class="line">git config --global http.proxy</span><br><span class="line">git config --global https.proxy</span><br></pre></td></tr></table></figure>
</blockquote>
<h3 id="2-2-2-由-DNS-解析异常导致"><a href="#2-2-2-由-DNS-解析异常导致" class="headerlink" title="2.2.2 由 DNS 解析异常导致"></a>2.2.2 由 DNS 解析异常导致</h3><p>若是由于 <strong>DNS 解析</strong>异常导致的，则使用如下方式解决：</p>
<ul>
<li>首先在 <a target="_blank" rel="noopener" href="https://www.ipaddress.com/">ipaddress.com</a> 网站搜索获取 GitHub 域名对应的 IP 地址。</li>
</ul>
<blockquote>
<p><strong>注</strong>：</p>
<ol>
<li>修改hosts文件,就修改了IP 地址和域名之间的映射关系。修改 hosts 文件域名解析就会访问 hosts 文件中的 IP和域名的映射关系以访问指定网站。</li>
<li>如果想要更加完整的 GitHub DNS 解析列表可在 Gitee 上查询相关仓库并将其更新到本地的 Hosts 文件当中。</li>
</ol>
</blockquote>
<ul>
<li>然后将 IP 地址和域名的映射关系写入系统的 hosts 文件中。</li>
</ul>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">在 Windows 系统中修改如下路径的 hosts 文件</span></span><br><span class="line">C:\Windows\System32\drivers\etc\hosts</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">在 Linux 系统中修改 hosts 文件</span></span><br><span class="line">sudo vim /etc/hosts</span><br></pre></td></tr></table></figure>



<h1 id="三-签名更新出错"><a href="#三-签名更新出错" class="headerlink" title="三.签名更新出错"></a>三.签名更新出错</h1><h2 id="3-1-问题描述"><a href="#3-1-问题描述" class="headerlink" title="3.1 问题描述"></a>3.1 问题描述</h2><p> 当 Manjaro 更新系统时，会出现如下签名失败的情况并导致软件更新失败</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">错误：archlinux-keyring: 来自 &quot;Christian Hesse &lt;eworm@archlinux.org&gt;&quot; 的签名是未知信任的</span><br><span class="line">:: 文件 /var/cache/pacman/pkg/archlinux-keyring-20221220-1-any.pkg.tar.zst 已损坏 (无效或已损坏的软件包 (PGP 签名)).</span><br><span class="line">打算删除吗？ [Y/n]</span><br></pre></td></tr></table></figure>



<h2 id="3-2-解决方法"><a href="#3-2-解决方法" class="headerlink" title="3.2 解决方法"></a>3.2 解决方法</h2><p>这儿可能会有两种情况出现</p>
<ol>
<li>第一种原因呢，是 <code>archlinux-keyring</code> 滚不动了。根本原因呢就是升级到了 <code>gnupg-2.1</code>，pacman 上游更新了密钥环的格式，这使得本地的主密钥无法签署其它密钥。。解决的思路是初始化 keyring 亦或者是将其更换为 <code>archlinuxcn-keyring</code>。本节参考的如下链接：<a target="_blank" rel="noopener" href="https://www.archlinuxcn.org/gnupg-2-1-and-the-pacman-keyring/">GnuPG-2.1 与 pacman 密钥环</a></li>
</ol>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">1,移除旧的 keys</span></span><br><span class="line">sudo rm -rf /etc/pacman.d/gnupg</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">2,初始化 pacman 的keys</span></span><br><span class="line">sudo pacman-key --init</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">3,加载签名的keys</span></span><br><span class="line">sudo pacman-key --populate</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">4,刷新升级已经签名的keys,这一步可以选择跳过</span></span><br><span class="line">sudo pacman-key --refresh-keys</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">5,清空并且下载新数据</span></span><br><span class="line">sudo pacman -Sc</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">6,安装archlinuxcn-keyring</span></span><br><span class="line">sudo pacman -S archlinuxcn-keyring</span><br></pre></td></tr></table></figure>

<p>然后再更新系统和软件，发现问题解决。</p>
<ol start="2">
<li>第二种情况呢，是 archlinuxcn 社区源的 keyring 包 archlinuxcn-keyring 由 <code>farseerfc</code> 的 key 签署验证，而 Arch Linux 官方 keyring 中包含了 <code>farseerfc</code> 的 key 。解决思路呢就是使用如下命令在本地信任 <code>farseerfc</code> 的 key。本节参照的如下链接：<a target="_blank" rel="noopener" href="https://www.archlinuxcn.org/archlinuxcn-keyring-manually-trust-farseerfc-key/">手动信任 farseerfc 的 key</a></li>
</ol>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">此 key 已随 archlinux-keyring 安装在系统中，只是缺乏信任</span></span><br><span class="line">sudo pacman-key --lsign-key &quot;farseerfc@archlinux.org&quot;</span><br></pre></td></tr></table></figure>

<p>然后再更新系统和软件，发现问题解决。</p>

      

      
    </div>
    <div class="article-info article-info-index">
      
      
	<div class="article-tag tagcloud">
		<i class="icon-price-tags icon"></i>
		<ul class="article-tag-list">
			 
        		<li class="article-tag-list-item">
        			<a href="javascript:void(0)" class="js-tag article-tag-list-link color1">Linux</a>
        		</li>
      		 
        		<li class="article-tag-list-item">
        			<a href="javascript:void(0)" class="js-tag article-tag-list-link color3">Manjaro</a>
        		</li>
      		
		</ul>
	</div>

      

      
        <p class="article-more-link">
          <a class="article-more-a" href="/2024/01/31/Manjaro%E4%BD%BF%E7%94%A8%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98%E6%B1%87%E6%80%BB/">展开全文 >></a>
        </p>
      

      
      <div class="clearfix"></div>
    </div>
  </div>
</article>

<aside class="wrap-side-operation">
    <div class="mod-side-operation">
        
        <div class="jump-container" id="js-jump-container" style="display:none;">
            <a href="javascript:void(0)" class="mod-side-operation__jump-to-top">
                <i class="icon-font icon-back"></i>
            </a>
            <div id="js-jump-plan-container" class="jump-plan-container" style="top: -11px;">
                <i class="icon-font icon-plane jump-plane"></i>
            </div>
        </div>
        
        
    </div>
</aside>




  
    <article id="post-Manjaro及常用软件安装配置" class="article article-type-post  article-index" itemscope itemprop="blogPost">
  <div class="article-inner">
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/2024/01/29/Manjaro%E5%8F%8A%E5%B8%B8%E7%94%A8%E8%BD%AF%E4%BB%B6%E5%AE%89%E8%A3%85%E9%85%8D%E7%BD%AE/">Manjaro及其常用软件安装配置</a>
    </h1>
  

        
        <a href="/2024/01/29/Manjaro%E5%8F%8A%E5%B8%B8%E7%94%A8%E8%BD%AF%E4%BB%B6%E5%AE%89%E8%A3%85%E9%85%8D%E7%BD%AE/" class="archive-article-date">
  	<time datetime="2024-01-29T14:00:40.000Z" itemprop="datePublished"><i class="icon-calendar icon"></i>2024-01-29</time>
</a>
        
      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <h1 id="前言"><a href="#前言" class="headerlink" title="前言"></a>前言</h1><p>Manjaro 是一个 Arch Linux 的发行版本</p>
<p>来自 Manjaro 社区的官方介绍：</p>
<p>Manjaro is a versatile, free, and open-source Linux operating system designed with a strong focus on safeguarding user privacy and offering extensive control over hardware. This user-friendly OS is an excellent choice for those who seek a fresh computing experience, as it can be seamlessly installed on a diverse array of devices. With support for both x86-64 and ARM architectures, Manjaro stands as an ideal option for any device or computing environment. Furthermore, Manjaro provides an array of customization options and a rich selection of applications, all while prioritizing security and privacy features. To cater to a wide audience.</p>
<h1 id="一-Manjaro安装"><a href="#一-Manjaro安装" class="headerlink" title="一.Manjaro安装"></a>一.Manjaro安装</h1><h2 id="1-1-安装包及工具获取"><a href="#1-1-安装包及工具获取" class="headerlink" title="1.1 安装包及工具获取"></a>1.1 安装包及工具获取</h2><h3 id="1-1-1-安装包获取"><a href="#1-1-1-安装包获取" class="headerlink" title="1.1.1 安装包获取"></a>1.1.1 安装包获取</h3><p>访问<a target="_blank" rel="noopener" href="https://manjaro.org/">Manjaro官网</a>的下载页可以看到，Manjaro 官方提供了三种桌面版本的 Manjaro 系统：Plasma、Xfce以及 GNOME。</p>
<ol>
<li>Plasma：是一种 KDE 桌面环境，其功能完善，自定义程度较高。对于硬件资源消耗较大</li>
<li>Xfce：是一种轻量级的桌面环境，其界面美观、对用户友好，它是由 C 语言编写而成，依赖于 GTK+。对资源消耗较小</li>
<li>GNOME：是一款GNU的桌面环境，Ubuntu 系统的默认桌面环境。对于资源消耗适中。</li>
</ol>
<div style="text-align: center;">
    <img src="https://dustwind-picture-upload.oss-cn-chengdu.aliyuncs.com/img/Manjaro%20Install/%E5%87%86%E5%A4%87%E9%98%B6%E6%AE%B5/Manjaro%E4%B8%8B%E8%BD%BD%E9%A1%B5.png" alt="Manjaro下载页"  />
</div>

<p>笔者曾使用 Ubuntu 系统，比较喜欢GNOME的桌面环境，因此笔者选择 GNOME Desktop 版本。</p>
<h3 id="1-1-2-写入工具选择"><a href="#1-1-2-写入工具选择" class="headerlink" title="1.1.2 写入工具选择"></a>1.1.2 写入工具选择</h3><p>当前市面上有许多U盘烧录工具，如Rufus、USBWriter、Ventoy等。</p>
<h2 id="1-2-写入盘制作"><a href="#1-2-写入盘制作" class="headerlink" title="1.2 写入盘制作"></a>1.2 写入盘制作</h2><p>笔者采用 Rufus 软件写入文件到U盘。打开 Rufus 软件之后默认会选择U盘，然后在引导类型选择栏选择需要安装的 Manjaro 镜像文件。然后点击开始按钮进行烧录。</p>
<div style="text-align: center;">
    <img src="https://dustwind-picture-upload.oss-cn-chengdu.aliyuncs.com/img/Manjaro%20Install/%E5%87%86%E5%A4%87%E9%98%B6%E6%AE%B5/Rusfus%E5%86%99%E5%85%A5%E8%BD%AF%E4%BB%B6.png" alt="Rufus写入软件"  />
</div>

<h2 id="1-3-安装步骤"><a href="#1-3-安装步骤" class="headerlink" title="1.3 安装步骤"></a>1.3 安装步骤</h2><p>将写入系统镜像的U盘插到待安装系统的电脑上。开机选择U盘启动项开始安装</p>
<h3 id="1-3-1-语言及驱动选择"><a href="#1-3-1-语言及驱动选择" class="headerlink" title="1.3.1 语言及驱动选择"></a>1.3.1 语言及驱动选择</h3><p>进入驱动选择界面，将地区（tz 项）选择为中国上海，语言（lang 项）设置为中文，然后驱动选择<Boot with proprietary drivers> 项并回车。</p>
<div style="text-align: center;">
    <img src="https://dustwind-picture-upload.oss-cn-chengdu.aliyuncs.com/img/Manjaro%20Install/%E5%AE%89%E8%A3%85%E9%98%B6%E6%AE%B5/1.%E9%80%89%E6%8B%A9%E9%A9%B1%E5%8A%A8%E7%B1%BB%E5%9E%8B.png" alt="选择驱动类型"  />
</div>

<blockquote>
<p><strong>注</strong>：</p>
<p>图中第一项 <Boot with open source drivers> 为开源驱动。</p>
<p>图中第二项 <Boot with proprietary drivers> 为闭源驱动。</p>
<p>由于笔者是英伟达显卡，故选择第二项进行安装。</p>
</blockquote>
<h3 id="1-3-2-载入内核与系统界面"><a href="#1-3-2-载入内核与系统界面" class="headerlink" title="1.3.2 载入内核与系统界面"></a>1.3.2 载入内核与系统界面</h3><ul>
<li>回车安装之后会载入内核界面</li>
</ul>
<div style="text-align: center;">
    <img src="https://dustwind-picture-upload.oss-cn-chengdu.aliyuncs.com/img/Manjaro%20Install/%E5%AE%89%E8%A3%85%E9%98%B6%E6%AE%B5/2.%E5%8A%A0%E8%BD%BD%E5%86%85%E6%A0%B8%E7%95%8C%E9%9D%A2.png" alt="载入内核界面"  />
</div>

<ul>
<li>成功之后便会显示系统 Logo 界面</li>
</ul>
<div style="text-align: center;">
    <img src="https://dustwind-picture-upload.oss-cn-chengdu.aliyuncs.com/img/Manjaro%20Install/%E5%AE%89%E8%A3%85%E9%98%B6%E6%AE%B5/3.%E7%B3%BB%E7%BB%9FLogo%E7%95%8C%E9%9D%A2.png" alt="系统Logo界面"  />
</div>

<h3 id="1-3-3-系统欢迎页"><a href="#1-3-3-系统欢迎页" class="headerlink" title="1.3.3 系统欢迎页"></a>1.3.3 系统欢迎页</h3><p>进入系统欢迎页。将语言选择为 <code>简体中文</code>，然后点击启动安装程序按钮开始安装。</p>
<div style="text-align: center;">
    <img src="https://dustwind-picture-upload.oss-cn-chengdu.aliyuncs.com/img/Manjaro%20Install/%E5%AE%89%E8%A3%85%E9%98%B6%E6%AE%B5/4.%E7%B3%BB%E7%BB%9F%E6%AC%A2%E8%BF%8E%E9%A1%B5.png" alt="系统欢迎页"  />
</div>

<h3 id="1-3-4-进入系统安装页"><a href="#1-3-4-进入系统安装页" class="headerlink" title="1.3.4 进入系统安装页"></a>1.3.4 进入系统安装页</h3><p>进入系统安装页，点击下一步正式开始安装</p>
<div style="text-align: center;">
    <img src="https://dustwind-picture-upload.oss-cn-chengdu.aliyuncs.com/img/Manjaro%20Install/%E5%AE%89%E8%A3%85%E9%98%B6%E6%AE%B5/5.%E8%BF%9B%E5%85%A5%E5%AE%89%E8%A3%85%E7%A8%8B%E5%BA%8F.png" alt="进入系统安装页"  />
</div>

<h3 id="1-3-5-地区及键盘布局"><a href="#1-3-5-地区及键盘布局" class="headerlink" title="1.3.5 地区及键盘布局"></a>1.3.5 地区及键盘布局</h3><ul>
<li>在系统安装页将地区设置为 <code>亚洲/上海</code>，然后点击下一步。</li>
</ul>
<div style="text-align: center;">
    <img src="https://dustwind-picture-upload.oss-cn-chengdu.aliyuncs.com/img/Manjaro%20Install/%E5%AE%89%E8%A3%85%E9%98%B6%E6%AE%B5/6.%E9%80%89%E6%8B%A9%E5%9C%B0%E5%8C%BA.png" alt="地区选择"  />
</div>

<ul>
<li>键盘布局选择默认布局，然后点击下一步。</li>
</ul>
<div style="text-align: center;">
    <img src="https://dustwind-picture-upload.oss-cn-chengdu.aliyuncs.com/img/Manjaro%20Install/%E5%AE%89%E8%A3%85%E9%98%B6%E6%AE%B5/7.%E9%80%89%E6%8B%A9%E9%94%AE%E7%9B%98%E5%B8%83%E5%B1%80.png" alt="键盘方式选择"  />
</div>



<h3 id="1-3-6-系统分区"><a href="#1-3-6-系统分区" class="headerlink" title="1.3.6 系统分区"></a>1.3.6 系统分区</h3><p>这一步非常关键，分区不正确将影响系统安装。此时出现两个选项，我们选择手动分区，然后点击下一步。</p>
<div style="text-align: center;">
    <img src="https://dustwind-picture-upload.oss-cn-chengdu.aliyuncs.com/img/Manjaro%20Install/%E5%AE%89%E8%A3%85%E9%98%B6%E6%AE%B5/8.0.%E9%80%89%E6%8B%A9%E5%88%86%E5%8C%BA%E6%96%B9%E5%BC%8F.png" alt="分区方式选择"  />
</div>


<p>进入到分区具体流程，笔者的分区如下表所述进行：</p>
<table>
<thead>
<tr>
<th align="center">大小</th>
<th align="center">文件系统</th>
<th align="center">挂载点</th>
<th align="center">标记</th>
<th align="center">备注</th>
</tr>
</thead>
<tbody><tr>
<td align="center">20GiB</td>
<td align="center">ext4</td>
<td align="center">&#x2F;</td>
<td align="center">root</td>
<td align="center">根目录，用于存放系统文件</td>
</tr>
<tr>
<td align="center">512MiB</td>
<td align="center">ext4</td>
<td align="center">&#x2F;boot</td>
<td align="center">boot或者bios-grub</td>
<td align="center">引导分区，系统启动相关</td>
</tr>
<tr>
<td align="center">4096MiB</td>
<td align="center">linuxswap</td>
<td align="center">无挂载点</td>
<td align="center">swap</td>
<td align="center">交换分区，一般与内存大小相同</td>
</tr>
<tr>
<td align="center">10Gib</td>
<td align="center">ext4</td>
<td align="center">&#x2F;var</td>
<td align="center">无标记</td>
<td align="center">存储变量</td>
</tr>
<tr>
<td align="center">The Rest</td>
<td align="center">ext4</td>
<td align="center">&#x2F;home</td>
<td align="center">无标记</td>
<td align="center">家目录，用于存放用户数据</td>
</tr>
</tbody></table>
<blockquote>
<p><strong>注</strong>：几个分区的具体介绍</p>
<ol>
<li>&#x2F; 分区，大小通常为15-20GiB。根分区是最重要而且必需的，需要最先挂载,因为包括 &#x2F;usr 目录，根据安装的软件数量，会产生非常明显的增长。</li>
<li>&#x2F;boot 分区，大小通常为512MiB。引导分区包含内核、ramdisk 镜像以及 bootloader 配置文件和bootloader stage。它也可以存放内核在执行用户态程序之前所使用的其他数据。&#x2F;boot 在日常系统运行中并不需要，只在启动和内核升级（包括重建initial ramdisk）的时候用到。如果使用软RAID0（条带化）系统的话，必须有一个独立的 &#x2F;boot 分区。不使用 UEFI 时，引导分区大小建议为 200 MiB，使用 UEFI 时，需要至少 512 MiB 空间。</li>
<li>linuxswap 分区，大小通常为内存的大小。</li>
<li>&#x2F;home 分区，将&#x2F;home目录独立使得&#x2F;分区可以单独重新划分，但是请注意你可以在 &#x2F;home 没有独立分区的情况下你仍然可以在不修改 &#x2F;home 目录内容的情况下重装 Arch —— 删除其他顶级目录，然后执行pacstrap。不能与使用其他发行版的用户共享同一个 home 目录，因为不同的发行版可能使用不兼容的软件版本和补丁。可以共享媒体目录，或至少使用 &#x2F;home 分区下的不同 home 目录。分区大小跟着存储的内容而定。</li>
<li>&#x2F;var 分区，存储变量数据例如 spool 目录和文件，管理和登录数据,它通常被用作缓存或者日志记录，因此读写频繁。将它独立出来可以避免由于大量日志写入造成的磁盘空间耗尽等问题。</li>
<li>除了其他数据以外，还包括 ABS 树和 pacman 缓存。保留缓存的包提供了包降级的能力，因此非常有用。也正因为这样，&#x2F;var 的大小会随着时间推移而增长。尤其是 pacman 缓存将会随着新软件的安装、系统的升级而增长。在磁盘空间不足的时候，可以安全的清理这个目录。&#x2F;var 分配 8-12 GB 对于桌面系统来说是比较合适的取值，具体取值取决于安装的软件数量。</li>
</ol>
</blockquote>
<ol>
<li>根目录（&#x2F;）</li>
</ol>
<div style="text-align: center;">
    <img src="https://dustwind-picture-upload.oss-cn-chengdu.aliyuncs.com/img/Manjaro%20Install/%E5%AE%89%E8%A3%85%E9%98%B6%E6%AE%B5/8.1.%E6%A0%B9%E5%88%86%E5%8C%BA%E9%85%8D%E7%BD%AE.png" alt="根分区配置"  />
</div>



<ol start="2">
<li>引导分区（&#x2F;boot或者&#x2F;boot&#x2F;efi）</li>
</ol>
<ul>
<li>当进行单系统（Manjaro）安装时，直接挂载 &#x2F;boot 引导分区</li>
</ul>
<div style="text-align: center;">
    <img src="https://dustwind-picture-upload.oss-cn-chengdu.aliyuncs.com/img/Manjaro%20Install/%E5%AE%89%E8%A3%85%E9%98%B6%E6%AE%B5/8.2.boot%E5%88%86%E5%8C%BA%E9%85%8D%E7%BD%AE.png" alt="单系统安装Boot分区配置"  />
</div>



<ul>
<li>当进行双系统（Windows+Manjaro）安装时，则需要将 &#x2F;boot&#x2F;efi 挂载到 Windows 的 ESP 引导分区上。注意配置 ESP 分区的时候选择保留分区而别格式化分区。</li>
</ul>
<div style="text-align: center;">
    <img src="https://dustwind-picture-upload.oss-cn-chengdu.aliyuncs.com/img/Manjaro%20Install/%E5%AE%89%E8%A3%85%E9%98%B6%E6%AE%B5/%E5%88%86%E5%8C%BA%E7%9A%84%E7%89%B9%E4%BE%8B/%E5%8F%8C%E7%B3%BB%E7%BB%9F%E7%9A%84%E7%B3%BB%E7%BB%9F%E5%BC%95%E5%AF%BC%E6%8C%82%E8%BD%BD%E6%96%B9%E6%A1%881.png" alt="双系统安装Boot分区配置"  />
</div>

<div style="text-align: center;">
    <img src="https://dustwind-picture-upload.oss-cn-chengdu.aliyuncs.com/img/Manjaro%20Install/%E5%AE%89%E8%A3%85%E9%98%B6%E6%AE%B5/%E5%88%86%E5%8C%BA%E7%9A%84%E7%89%B9%E4%BE%8B/%E5%8F%8C%E7%B3%BB%E7%BB%9F%E7%9A%84%E7%B3%BB%E7%BB%9F%E5%BC%95%E5%AF%BC%E6%8C%82%E8%BD%BD%E6%96%B9%E6%A1%882.png" alt="双系统安装Boot分区配置"  />
</div>

<blockquote>
<p><strong>注</strong>：</p>
<p>手动挂载&#x2F;boot&#x2F;efi分区的方法可以参考如下文章：<a target="_blank" rel="noopener" href="https://blog.csdn.net/qq_44639125/article/details/125707257?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522170654013516800213030099%2522%252C%2522scm%2522%253A%252220140713.130102334..%2522%257D&request_id=170654013516800213030099&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~all~baidu_landing_v2~default-4-125707257-null-null.142%5Ev99%5Epc_search_result_base4&utm_term=Manjaro%E5%AE%89%E8%A3%85%E5%88%86%E5%8C%BA&spm=1018.2226.3001.4187">manjaro 手动挂载&#x2F;boot&#x2F;efi分区</a></p>
</blockquote>
<ol start="3">
<li>交换分区（linuxswap）</li>
</ol>
<div style="text-align: center;">
    <img src="https://dustwind-picture-upload.oss-cn-chengdu.aliyuncs.com/img/Manjaro%20Install/%E5%AE%89%E8%A3%85%E9%98%B6%E6%AE%B5/8.3.swap%E5%88%86%E5%8C%BA%E9%85%8D%E7%BD%AE.png" alt="交换分区配置"  />
</div>



<ol start="4">
<li>家目录（&#x2F;home）</li>
</ol>
<div style="text-align: center;">
    <img src="https://dustwind-picture-upload.oss-cn-chengdu.aliyuncs.com/img/Manjaro%20Install/%E5%AE%89%E8%A3%85%E9%98%B6%E6%AE%B5/8.4.home%E5%88%86%E5%8C%BA%E9%85%8D%E7%BD%AE%EF%BC%88%E5%89%A9%E4%B8%8B%E5%85%A8%E9%83%A8%EF%BC%89.png" alt="home分区配置"  />
</div>



<ol start="5">
<li>最终生成的分区方案</li>
</ol>
<div style="text-align: center;">
    <img src="https://dustwind-picture-upload.oss-cn-chengdu.aliyuncs.com/img/Manjaro%20Install/%E5%AE%89%E8%A3%85%E9%98%B6%E6%AE%B5/8.5.%E6%9C%80%E7%BB%88%E5%88%86%E5%8C%BA%E6%96%B9%E6%A1%88.png" alt="最终分区方案"  />
</div>



<h3 id="1-3-7-用户名及密码设置"><a href="#1-3-7-用户名及密码设置" class="headerlink" title="1.3.7 用户名及密码设置"></a>1.3.7 用户名及密码设置</h3><p>在系统安装页的用户名界面输入自己的登录用户名并设置它对应的用户密码。如果嫌用户密码和管理员密码分别设置很麻烦就勾选 <code>&lt;为管理员账号使用同样的密码&gt;</code>。然后点击下一步。</p>
<div style="text-align: center;">
    <img src="https://dustwind-picture-upload.oss-cn-chengdu.aliyuncs.com/img/Manjaro%20Install/%E5%AE%89%E8%A3%85%E9%98%B6%E6%AE%B5/9.%E8%AE%BE%E7%BD%AE%E8%AE%A1%E7%AE%97%E6%9C%BA%E5%90%8D%E5%AD%97%E5%8F%8A%E5%AF%86%E7%A0%81.png" alt="用户名及密码"  />
</div>


<h3 id="1-3-8-Office套件"><a href="#1-3-8-Office套件" class="headerlink" title="1.3.8 Office套件"></a>1.3.8 Office套件</h3><p>在系统安装页，Manjaro 提供了多种 Office 套件以供选择，笔者选择的是 LibreOffice。如果这几种都不喜欢可以跳过自行安装 WPS 。</p>
<div style="text-align: center;">
    <img src="https://dustwind-picture-upload.oss-cn-chengdu.aliyuncs.com/img/Manjaro%20Install/%E5%AE%89%E8%A3%85%E9%98%B6%E6%AE%B5/10.%E9%80%89%E6%8B%A9office%E5%8A%9E%E5%85%AC%E5%A5%97%E4%BB%B6.png" alt="Office套件选择"  />
</div>

<h3 id="1-3-9-开始系统安装"><a href="#1-3-9-开始系统安装" class="headerlink" title="1.3.9 开始系统安装"></a>1.3.9 开始系统安装</h3><ul>
<li>Office 套件选择完毕后点击下一步便开始系统安装，此时会生成一个系统安装的摘要，显示之后点击安装。</li>
</ul>
<div style="text-align: center;">
    <img src="https://dustwind-picture-upload.oss-cn-chengdu.aliyuncs.com/img/Manjaro%20Install/%E5%AE%89%E8%A3%85%E9%98%B6%E6%AE%B5/11.%E7%B3%BB%E7%BB%9F%E5%AE%89%E8%A3%85%E6%91%98%E8%A6%81.png" alt="系统安装摘要"  />
</div>



<ul>
<li>此时会弹出一个消息框，选择现在安装继续进行</li>
</ul>
<div style="text-align: center;">
    <img src="https://dustwind-picture-upload.oss-cn-chengdu.aliyuncs.com/img/Manjaro%20Install/%E5%AE%89%E8%A3%85%E9%98%B6%E6%AE%B5/12.%E5%AE%89%E8%A3%85%E6%8F%90%E7%A4%BA.png" alt="安装提示"  />
</div>



<ul>
<li>系统开始安装，点击进度条右边的小红点可以查看系统安装详细信息</li>
</ul>
<div style="text-align: center;">
    <img src="https://dustwind-picture-upload.oss-cn-chengdu.aliyuncs.com/img/Manjaro%20Install/%E5%AE%89%E8%A3%85%E9%98%B6%E6%AE%B5/13.%E7%B3%BB%E7%BB%9F%E5%AE%89%E8%A3%85%E7%95%8C%E9%9D%A2.png" alt="开始系统安装"  />
</div>



<ul>
<li>系统安装完毕，勾选现在重启然后重启系统便可以正常使用了。</li>
</ul>
<div style="text-align: center;">
    <img src="https://dustwind-picture-upload.oss-cn-chengdu.aliyuncs.com/img/Manjaro%20Install/%E5%AE%89%E8%A3%85%E9%98%B6%E6%AE%B5/14.%E5%AE%89%E8%A3%85%E7%BB%93%E6%9D%9F.png" alt="系统安装完毕"  />
</div>


<h1 id="二-系统换源"><a href="#二-系统换源" class="headerlink" title="二.系统换源"></a>二.系统换源</h1><p>为了保证 Manjaro 系统下载软件的流畅性，通常需要将软件源更改为国内高校或者阿里腾讯等互联网大厂的软件镜像源。以下部分将介绍镜像源配置流程。</p>
<h2 id="2-1-获取源列表并换源"><a href="#2-1-获取源列表并换源" class="headerlink" title="2.1 获取源列表并换源"></a>2.1 获取源列表并换源</h2><ol>
<li>执行如下命令出现镜像源复选框：</li>
</ol>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo pacman-mirrors -c China -i -m rank</span><br></pre></td></tr></table></figure>

<ol start="2">
<li>在弹出的复选框中选择自己所需的镜像源并点击确认生效。</li>
</ol>
<div style="text-align: center;">
    <img src="https://dustwind-picture-upload.oss-cn-chengdu.aliyuncs.com/img/Manjaro%20Install/%E6%9B%B4%E6%96%B0%E6%BA%90/1.%E6%89%A7%E8%A1%8C%E5%91%BD%E4%BB%A4.png" alt="选择镜像源"  />
</div>

<ol start="3">
<li>镜像源生效之后会将配置写入到 &#96;&#96;&#x2F;etc&#x2F;pacman.d&#x2F;mirrorlist&#96; 文件当中。</li>
</ol>
<div style="text-align: center;">
    <img src="https://dustwind-picture-upload.oss-cn-chengdu.aliyuncs.com/img/Manjaro%20Install/%E6%9B%B4%E6%96%B0%E6%BA%90/2.%E9%80%89%E6%8B%A9%E5%B9%B6%E7%A1%AE%E5%AE%9A%E9%95%9C%E5%83%8F%E6%BA%90.png" alt="镜像源生效"  />
</div>
4. 最后执行如下命令更新软件与系统

<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo pacman -Syyu</span><br></pre></td></tr></table></figure>



<h2 id="2-2-Arch源更换"><a href="#2-2-Arch源更换" class="headerlink" title="2.2 Arch源更换"></a>2.2 Arch源更换</h2><p>将 <code>archlinuxcn</code> 和 <code>arch4edu</code> 的源也更换一下。</p>
<ol>
<li>使用 gedit 程序命令访问配置文件</li>
</ol>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo gedit /etc/pacman.conf</span><br></pre></td></tr></table></figure>

<ol start="2">
<li>然后在文件末尾添加如下内容并保存</li>
</ol>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line">[archlinuxcn]</span><br><span class="line">SigLevel = TrustedOnly</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">阿里源</span></span><br><span class="line">Server = https://mirrors.aliyun.com/archlinuxcn/$arch</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">中科大源</span></span><br><span class="line">Server = https://mirrors.ustc.edu.cn/archlinuxcn/$arch</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">163源</span></span><br><span class="line">Server = http://mirrors.163.com/archlinux-cn/$arch</span><br><span class="line"></span><br><span class="line">[arch4edu]</span><br><span class="line">SigLevel = Optional TrustAll</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">阿里edu源</span></span><br><span class="line">Server = https://mirrors.aliyun.com/arch4edu/$arch</span><br></pre></td></tr></table></figure>

<div style="text-align: center;">
    <img src="https://dustwind-picture-upload.oss-cn-chengdu.aliyuncs.com/img/Manjaro%20Install/%E6%9B%B4%E6%96%B0%E6%BA%90/4.%E5%8A%A0%E5%85%A5archlinuxcn%E5%92%8Carch4edu%E6%BA%90.png" alt="更换archlinuxcn和arch4edu源"  />
</div>
3. 最后执行如下命令更新软件与系统

<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo pacman -Syyu</span><br></pre></td></tr></table></figure>



<h1 id="三-常用软件安装"><a href="#三-常用软件安装" class="headerlink" title="三.常用软件安装"></a>三.常用软件安装</h1><h2 id="3-1-输入法安装"><a href="#3-1-输入法安装" class="headerlink" title="3.1 输入法安装"></a>3.1 输入法安装</h2><p>笔者在 Windows 系统上多年都是使用的搜狗输入法。但是由于 Qt 版本的更新，搜狗官方并未在 Linux 下推出新架构的搜狗拼音输入法，因此笔者选择安装 fcitx5 输入法并配置相应的环境。当然，本节也会提供 Fcitx 框架下搜狗输入法的安装。</p>
<blockquote>
<p><strong>注</strong>：</p>
<ul>
<li><p>两种输入法安装的步骤都是：框架+具体输入法的形式进行</p>
</li>
<li><p>Fcitx 和 Fcitx5 两种框架都提供基本的输入法</p>
</li>
</ul>
</blockquote>
<h3 id="3-1-1-Fcitx5-输入法安装"><a href="#3-1-1-Fcitx5-输入法安装" class="headerlink" title="3.1.1 Fcitx5 输入法安装"></a>3.1.1 Fcitx5 输入法安装</h3><p>Fcitx5 是一个输入法框架，它具有轻量级内核，并通过 addon 提供额外的语言支持。Fcitx5 接替 Fcitx 。</p>
<ol>
<li>Fcitx5 依赖安装</li>
</ol>
<p>安装 Fcitx5 输入法首先需要下载 fcitx5 的依赖包。通过如下命令安装这些依赖包：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">------------------------------------------------------------------------------ <span class="comment">#</span></span>  </span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">由于之前装过 Fcitx ，所以需先卸载</span></span><br><span class="line">sudo pacman -Rs $(pacman -Qsq fcitx)</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">------------------------------------------------------------------------------ <span class="comment">#</span></span> </span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">Fcitx5 本体</span></span><br><span class="line">sudo pacman -S fcitx5 </span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">------------------------------------------------------------------------------ <span class="comment">#</span></span> </span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">集成了[fctxi5]、[fctxi5-configtool]、[fctxi5-gtk]、[fctxi5-qt]</span></span><br><span class="line">sudo pacman -S fcitx5-im</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">------------------------------------------------------------------------------ <span class="comment">#</span></span> </span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">Fcitx5 配置工具</span></span><br><span class="line">sudo pacman -S fcitx5-configtool  </span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">------------------------------------------------------------------------------ <span class="comment">#</span></span> </span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">对 Qt 程序软件的支持</span></span><br><span class="line">sudo pacman -S fcitx5-qt		# 集成 Qt5 和 Qt6 依赖库</span><br><span class="line">sudo pacman -S fcitx5-qt4		# 单独集成 Qt4 依赖库</span><br><span class="line">sudo pacman -S fcitx5-qt5-git		# 单独集成 Qt5 依赖库</span><br><span class="line">sudo pacman -S fcitx5-qt6-git		# 单独集成 Qt6 依赖库</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">------------------------------------------------------------------------------ <span class="comment">#</span></span> </span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">Fcitx5 对于 GTK 程序的支持</span></span><br><span class="line">sudo pacman -S fcitx5-gtk</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">------------------------------------------------------------------------------ <span class="comment">#</span></span> </span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">Fcitx5 对于中文相关的 addon，例如拼音、双拼和五笔</span></span><br><span class="line">sudo pacman -S fcitx5-chinese-addons</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">------------------------------------------------------------------------------ <span class="comment">#</span></span> </span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">Fcitx5 的第三方主题库</span></span><br><span class="line">sudo pacman -S fcitx5-material-color</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">------------------------------------------------------------------------------ <span class="comment">#</span></span> </span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">Fcitx5 对 KDE 桌面环境的支持</span></span><br><span class="line">sudo pacman -S kcm-fcitx5</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">------------------------------------------------------------------------------ <span class="comment">#</span></span> </span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">Fcitx5 对日期时间的支持</span></span><br><span class="line">sudo pacman -S fcitx5-lua</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">------------------------------------------------------------------------------ <span class="comment">#</span></span> </span><br></pre></td></tr></table></figure>

<p>通常想要运行 Fcitx5 的输入法环境只需要安装 fcitx5-im 即可，如果有更多定制化操作可视情况而定。</p>
<ol start="2">
<li>Fcitx5 环境配置</li>
</ol>
<p>访问 <code>/etc/environment</code> 文件并将如下内容追加到文件末尾：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">GTK_IM_MODULE=fcitx5</span><br><span class="line">QT_IM_MODULE=fcitx5</span><br><span class="line">XMODIFIERS=@im=fcitx5</span><br><span class="line">SDL_IM_MODULE=fcitx5</span><br><span class="line">INPUT_METHOD=fcitx5</span><br><span class="line">GLFW_IM_MODULE=fcitx</span><br></pre></td></tr></table></figure>

<p>然后注销登陆重启输入法或者重启系统即可，如果想要添加词库，可运行 <code>Fcitx5</code> 配置软件对拼音输入法进行配置。</p>
<h3 id="3-1-2-Fcitx-输入法安装"><a href="#3-1-2-Fcitx-输入法安装" class="headerlink" title="3.1.2 Fcitx 输入法安装"></a>3.1.2 Fcitx 输入法安装</h3><ul>
<li>安装搜狗输入法首先需要下载 <code>Fcitx</code> 的依赖包。通过如下命令安装这些依赖包：</li>
</ul>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo pacman -S fcitx fcitx-configtool fcitx-gtk2 fcitx-gtk3 fcitx-qt5 fcitx-qt6</span><br></pre></td></tr></table></figure>

<ul>
<li>然后访问 ~&#x2F;.xprofile 文件并在末尾追加如下内容：</li>
</ul>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">export GTK_IM_MODULE=fcitx</span><br><span class="line">export QT_IM_MODULE=fcitx</span><br><span class="line">export XMODIFIERS=&quot;@im=fcitx&quot;</span><br></pre></td></tr></table></figure>



<blockquote>
<p><strong>注</strong>：</p>
<p>本文是对 ~&#x2F;.xprofile 文件进行的操作，也可以对 &#x2F;etc&#x2F;environment 文件进行上述相同的操作。如果不进行环境的配置，那么重启之后不能正常切换输入法，也就不能输入中文。</p>
<p>下面对几个环境变量配置文件进行简单介绍：</p>
<ul>
<li><p>profile: 每次终端登录时读取</p>
</li>
<li><p>bashrc: 每次终端登录时读取。</p>
</li>
<li><p>xinitrc: 每次startx启动Xwindows服务时读取</p>
</li>
<li><p>xprofile: 每次使用gdm、lightdm等图形登录管理器时读取。</p>
</li>
<li><p>environment：在所有用户登陆时都有效。</p>
</li>
</ul>
</blockquote>
<h3 id="3-1-3-搜狗输入法安装"><a href="#3-1-3-搜狗输入法安装" class="headerlink" title="3.1.3 搜狗输入法安装"></a>3.1.3 搜狗输入法安装</h3><p>AUR 提供了 fcitx-sogoupinyin 和 fcitx5-sogoupinyin 两个版本的输入法，笔者采用的是 fcitx-sogoupinyin 这一版本。下面正式开始搜狗输入法安装：</p>
<ul>
<li>然后通过从 <a target="_blank" rel="noopener" href="https://aur.archlinux.org/packages?O=0&SeB=nd&K=sogou&outdated=&SB=p&SO=d&PP=50&submit=Go">AUR</a> 上给拉取软件包 git 链接到本地</li>
</ul>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">git clone &lt;Target Source Address&gt;</span><br></pre></td></tr></table></figure>

<ul>
<li>然后进入项目文件夹直接开始构建安装软件包</li>
</ul>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">cd fcitx-sogoupinyin</span><br><span class="line">makepkg -si</span><br></pre></td></tr></table></figure>

<p>此时会出现如下图所示的错误：</p>
<div style="text-align: center;">
    <img src="https://dustwind-picture-upload.oss-cn-chengdu.aliyuncs.com/img/Manjaro%20Install/%E8%BD%AF%E4%BB%B6%E5%AE%89%E8%A3%85/%E6%90%9C%E7%8B%97%E6%8B%BC%E9%9F%B3%E5%AE%89%E8%A3%85.png" alt="搜狗拼音安装"  />
</div>

<p>这一错误会导致需要安装的 deb 包下载失败，从而导致整个安装过程的失败。为了避免此错误，笔者采用的方式是从 <a target="_blank" rel="noopener" href="https://shurufa.sogou.com/">搜狗拼音输入法官网</a> 下载 deb 包放到此项目文件夹中，然后使用 PKGBUILD 文件构建安装软件包。不出意外的话，搜狗拼音输入法就安装完毕了。</p>
<ul>
<li>最后重启 Manjaro 系统，然后在 Fcitx 配置软件中将搜狗拼音输入法添加为第二输入法。这样就可以正常使用了。</li>
</ul>
<div style="text-align: center;">
    <img src="https://dustwind-picture-upload.oss-cn-chengdu.aliyuncs.com/img/Manjaro%20Install/%E8%BD%AF%E4%BB%B6%E5%AE%89%E8%A3%85/Fcitx%E9%85%8D%E7%BD%AE%E6%90%9C%E7%8B%97%E6%8B%BC%E9%9F%B3%E8%BE%93%E5%85%A5%E6%B3%95.png" alt="Fcitx配置搜狗输入法"  />
</div>


<h3 id="3-1-4-搜狗输入法安装导致问题"><a href="#3-1-4-搜狗输入法安装导致问题" class="headerlink" title="3.1.4 搜狗输入法安装导致问题"></a>3.1.4 搜狗输入法安装导致问题</h3><p>笔者安装了搜狗输入法进而导致了系统关机以及系统重启时会 <code>user@1000.service</code> 服务关闭异常。而将搜狗输入法卸载之后一切恢复到正常。</p>
<p>解决此问题的思路：</p>
<ol>
<li>启用 <code>debug-shell.sevice</code> 服务</li>
</ol>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo systemctl enable debug-shell.service</span><br></pre></td></tr></table></figure>

<ol start="2">
<li>关机出现问题时使用 <code>Alt+F9</code> 进入 shell 调试命令行</li>
<li>使用 systemctl status 命令查看正在运行的服务</li>
</ol>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo systemctl list-unit-files --type=service | grep enabled</span><br></pre></td></tr></table></figure>

<p>此时发现了 <code>user@1000.service</code> 仍在运行</p>
<ol start="4">
<li>使用 systemctl status 命令继续查看 <a href="mailto:&#117;&#x73;&#x65;&#114;&#64;&#x31;&#48;&#x30;&#x30;&#46;&#x73;&#x65;&#x72;&#118;&#x69;&#99;&#x65;">&#117;&#x73;&#x65;&#114;&#64;&#x31;&#48;&#x30;&#x30;&#46;&#x73;&#x65;&#x72;&#118;&#x69;&#99;&#x65;</a> 服务</li>
</ol>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo systemctl status user@1000.service</span><br></pre></td></tr></table></figure>

<p>此时便定位到了 <code>user@1000.service</code> 服务下的 sogoupinyin -service 子服务仍然在运行。</p>
<h2 id="3-2-回滚工具安装"><a href="#3-2-回滚工具安装" class="headerlink" title="3.2 回滚工具安装"></a>3.2 回滚工具安装</h2><p>使用如下命令可以安装回滚工具（TimeShift）：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo pacman -S timeshift</span><br></pre></td></tr></table></figure>



<h2 id="3-3-Chrome-浏览器安装"><a href="#3-3-Chrome-浏览器安装" class="headerlink" title="3.3 Chrome 浏览器安装"></a>3.3 Chrome 浏览器安装</h2><p>使用如下命令可以安装谷歌浏览器（google-chrome）：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo pacman -S google-chrome</span><br></pre></td></tr></table></figure>



<h2 id="3-4-Clash-软件安装"><a href="#3-4-Clash-软件安装" class="headerlink" title="3.4 Clash 软件安装"></a>3.4 Clash 软件安装</h2><p><strong>来自官网的介绍</strong>：Clash for Windows 是代理工具 Clash 在 Windows 系统的唯一图形客户端，同时还支持Windows、Linux、macOS 三大系统，功能强大且支持多种代理协议，如 Shadowsocks(SS)、ShadowsocksR(SSR)、Socks、Snell、V2Ray、Trojan 等代理协议。由于不知名原因，Clash for Windows 的作者已在 Github 上删库跑路，最终版本停在了 0.20.39 版本。</p>
<ol>
<li><p>首先下载 Clash for Windows 软件的 deb 软件包。在 Github 上有许多备份包可供下载，这里不再赘述。</p>
</li>
<li><p>然后通过 <code>debtap</code> 命令将 Clash for Windows 软件的 deb 包转换包格式。详细如下截图所示：</p>
</li>
</ol>
<div style="text-align: center;">
    <img src="https://dustwind-picture-upload.oss-cn-chengdu.aliyuncs.com/img/Manjaro%20Install/%E8%BD%AF%E4%BB%B6%E5%AE%89%E8%A3%85/Clash%E8%BD%AF%E4%BB%B6%E8%BD%AC%E5%8C%85.png" alt="Clash转包"  />
</div>

<ol start="3">
<li>打包完成后会生成一个 &#96;&#96;.pkg.tar.zst<code>的软件包，然后通过</code>pacman&#96; 命令进行本地安装</li>
</ol>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo pacman -U &lt;Packge Name&gt;</span><br></pre></td></tr></table></figure>

<div style="text-align: center;">
    <img src="https://dustwind-picture-upload.oss-cn-chengdu.aliyuncs.com/img/Manjaro%20Install/%E8%BD%AF%E4%BB%B6%E5%AE%89%E8%A3%85/Clash%E8%BD%AF%E4%BB%B6%E5%AE%89%E8%A3%85.png" alt="Clash本地安装"  />
</div>

<ol start="4">
<li>想要正常使用，还需要设置系统网络代理，下图展示的是笔者的代理参数：</li>
</ol>
<div style="text-align: center;">
    <img src="https://dustwind-picture-upload.oss-cn-chengdu.aliyuncs.com/img/Manjaro%20Install/%E8%BD%AF%E4%BB%B6%E5%AE%89%E8%A3%85/Clash%E7%B3%BB%E7%BB%9F%E4%BB%A3%E7%90%86.png" alt="设置系统网络代理"  />
</div>

<blockquote>
<p><strong>注</strong>：</p>
<p>这里的端口对应的是软件 UI 界面上 Port 栏目的端口号。</p>
<p>此外，想正常科学上网还需要相应的订阅节点，网上有很多免费节点可用， 这里便不再展开。</p>
</blockquote>
<p>至此，Clash for Windows 的 Manjaro 版本便安装完毕。</p>
<h2 id="3-5-QQ-安装"><a href="#3-5-QQ-安装" class="headerlink" title="3.5 QQ 安装"></a>3.5 QQ 安装</h2><p>近年来，随着国产 Linux 发行版的兴起。QQ 也顺应时代通过 QQNT（Electron）技术对原先的腾讯QQ进行改造并至今发布多个版本。可以通过以下命令进行安装：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">yay -S linuxqq</span><br></pre></td></tr></table></figure>



<h2 id="3-6-QQ音乐安装"><a href="#3-6-QQ音乐安装" class="headerlink" title="3.6 QQ音乐安装"></a>3.6 QQ音乐安装</h2><p>在 AUR 社区可以看到 @<a target="_blank" rel="noopener" href="https://aur.archlinux.org/account/Hill-98">Hill-98</a> 大佬有两个版本的 QQ音乐软件包。</p>
<ul>
<li><p>1.1.5-8 版本对应的名称为：<a target="_blank" rel="noopener" href="https://aur.archlinux.org/packages/qqmusic-electron">qqmusic-electron</a></p>
</li>
<li><p>1.1.5-1 版本对应的名称为：<a target="_blank" rel="noopener" href="https://aur.archlinux.org/packages/qqmusic-bin">qqmusic-bin</a></p>
</li>
</ul>
<p>在这里，笔者使用了更高版本的 qqmusic-electron ，具体安装参照如下命令：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">yay -S qqmusic-electron </span><br></pre></td></tr></table></figure>



<h2 id="3-7-顶部栏隐藏"><a href="#3-7-顶部栏隐藏" class="headerlink" title="3.7 顶部栏隐藏"></a>3.7 顶部栏隐藏</h2><p>此插件的功能是当应用最大化时能自动隐藏顶部栏，此软件通过 yay 安装即可。</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">yay -S gnome-shell-extension-hidetopbar-git</span><br></pre></td></tr></table></figure>



<h2 id="3-8-WPS-Office-套件安装"><a href="#3-8-WPS-Office-套件安装" class="headerlink" title="3.8 WPS Office 套件安装"></a>3.8 WPS Office 套件安装</h2><p>使用如下命令即可安装 WPS 套件：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">WPS软件本体（国际版）</span></span><br><span class="line">yay -S wps-office</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">WPS的中文语言包</span></span><br><span class="line">yay -S wps-office-mui-zh-cn</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">WPS的符号依赖包</span></span><br><span class="line">yay -S ttf-wps-fonts</span><br></pre></td></tr></table></figure>



<blockquote>
<p><strong>注</strong>：</p>
<ol>
<li><p>开始安装会报错，需要先安装文件 base-devel 库文件</p>
</li>
<li><p>安装完毕后依然无法使用wps pdf软件。需安装 libtiff5 库文件</p>
</li>
<li><p>更多问题可参考 <a target="_blank" rel="noopener" href="https://wiki.archlinuxcn.org/wiki/WPS_Office">WPS Office Wiki</a></p>
</li>
</ol>
</blockquote>
<h2 id="3-9-GitHub-Desktop-安装"><a href="#3-9-GitHub-Desktop-安装" class="headerlink" title="3.9 GitHub Desktop 安装"></a>3.9 GitHub Desktop 安装</h2><p>Github Desktop 在 AUR 上有相应的包，这里可以通过如下命令安装：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">AUR上有许多版本，这里选用的是中文版</span></span><br><span class="line">yay -S github-desktop-zh-bin</span><br></pre></td></tr></table></figure>



<h2 id="3-10-笔记软件"><a href="#3-10-笔记软件" class="headerlink" title="3.10 笔记软件"></a>3.10 笔记软件</h2><p>由于 <code>Notepad++</code> 并不支持众多 Linux 系统，所以可以使用 <code>Notepadqq</code> 、 <code>NotepadNext</code>  或者是 <code>Notepad--</code> 软件平替。当然，如果需要书写 Markdown 格式笔记更加流畅的体验，可以安装 <code>Typora</code> 软件。</p>
<ol>
<li><code>Notepadqq</code> 软件安装：</li>
</ol>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">yay -S notepadqq</span><br></pre></td></tr></table></figure>



<ol start="2">
<li><code>NotepadNext</code> 软件安装：</li>
</ol>
<p>本软件在 AUR 中暂时没有收录，且无 deb 包提供，仅提供了 AppImage 格式的软件包，因此笔者的此软件就是通过 AppImage 包安装的。这里附上此软件的 AppImage 软件包链接：<a target="_blank" rel="noopener" href="https://github.com/dail8859/NotepadNext">NotepadNext</a></p>
<ol start="3">
<li><code>Notepad--</code> 软件安装：</li>
</ol>
<p>此软件是对于 <code>Notepad++</code> 的国产软件替代，笔者也相当推荐使用此软件。</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">此处有三个 `-`</span></span><br><span class="line">yay -S notepad---bin</span><br></pre></td></tr></table></figure>



<ol start="3">
<li><code>Typora</code> 软件安装：</li>
</ol>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">yay -S typora</span><br></pre></td></tr></table></figure>


      

      
    </div>
    <div class="article-info article-info-index">
      
      
	<div class="article-tag tagcloud">
		<i class="icon-price-tags icon"></i>
		<ul class="article-tag-list">
			 
        		<li class="article-tag-list-item">
        			<a href="javascript:void(0)" class="js-tag article-tag-list-link color1">Linux</a>
        		</li>
      		 
        		<li class="article-tag-list-item">
        			<a href="javascript:void(0)" class="js-tag article-tag-list-link color3">Manjaro</a>
        		</li>
      		
		</ul>
	</div>

      

      
        <p class="article-more-link">
          <a class="article-more-a" href="/2024/01/29/Manjaro%E5%8F%8A%E5%B8%B8%E7%94%A8%E8%BD%AF%E4%BB%B6%E5%AE%89%E8%A3%85%E9%85%8D%E7%BD%AE/">展开全文 >></a>
        </p>
      

      
      <div class="clearfix"></div>
    </div>
  </div>
</article>

<aside class="wrap-side-operation">
    <div class="mod-side-operation">
        
        <div class="jump-container" id="js-jump-container" style="display:none;">
            <a href="javascript:void(0)" class="mod-side-operation__jump-to-top">
                <i class="icon-font icon-back"></i>
            </a>
            <div id="js-jump-plan-container" class="jump-plan-container" style="top: -11px;">
                <i class="icon-font icon-plane jump-plane"></i>
            </div>
        </div>
        
        
    </div>
</aside>




  
    <article id="post-Win11环境下WSL2的子系统部署" class="article article-type-post  article-index" itemscope itemprop="blogPost">
  <div class="article-inner">
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/2023/11/15/Win11%E7%8E%AF%E5%A2%83%E4%B8%8BWSL2%E7%9A%84%E5%AD%90%E7%B3%BB%E7%BB%9F%E9%83%A8%E7%BD%B2/">WSL2的子系统部署</a>
    </h1>
  

        
        <a href="/2023/11/15/Win11%E7%8E%AF%E5%A2%83%E4%B8%8BWSL2%E7%9A%84%E5%AD%90%E7%B3%BB%E7%BB%9F%E9%83%A8%E7%BD%B2/" class="archive-article-date">
  	<time datetime="2023-11-15T12:00:45.000Z" itemprop="datePublished"><i class="icon-calendar icon"></i>2023-11-15</time>
</a>
        
      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <h1 id="一-WSL2下Linux系统的安装"><a href="#一-WSL2下Linux系统的安装" class="headerlink" title="一.WSL2下Linux系统的安装"></a>一.WSL2下Linux系统的安装</h1><h2 id="1-1-先期工作"><a href="#1-1-先期工作" class="headerlink" title="1.1 先期工作"></a>1.1 先期工作</h2><ol>
<li>打开控制面板选择程序与功能项</li>
</ol>
<p><img src="https://dustwind-picture-upload.oss-cn-chengdu.aliyuncs.com/img/%E6%8E%A7%E5%88%B6%E9%9D%A2%E6%9D%BF.png" alt="打开控制面板选择程序与功能"></p>
<ol start="2">
<li>打开</li>
</ol>
<p><img src="https://dustwind-picture-upload.oss-cn-chengdu.aliyuncs.com/img/%E7%A8%8B%E5%BA%8F%E4%B8%8E%E5%8A%9F%E8%83%BD.png" alt="选择启用或者关闭Windows功能"></p>
<ol start="3">
<li>启用虚拟机服务相关配置项</li>
</ol>
<p><img src="https://dustwind-picture-upload.oss-cn-chengdu.aliyuncs.com/img/%E5%8B%BE%E9%80%89%E8%99%9A%E6%8B%9F%E6%9C%BA%E7%9B%B8%E5%85%B3%E9%85%8D%E7%BD%AE%E9%A1%B9.png" alt="启用虚拟机相关服务"></p>
<h2 id="1-2-检查WSL2"><a href="#1-2-检查WSL2" class="headerlink" title="1.2 检查WSL2"></a>1.2 检查WSL2</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">wsl --update</span><br></pre></td></tr></table></figure>

<blockquote>
<p>出现如下问题的解决方法：</p>
<p>Error: 0x80d03805</p>
<p>Error code: Wsl&#x2F;UpdatePackage&#x2F;0x80d03805</p>
<p>重启系统重新输入命令行发现此问题消失</p>
</blockquote>
<h2 id="1-3-设置WSL的默认版本"><a href="#1-3-设置WSL的默认版本" class="headerlink" title="1.3 设置WSL的默认版本"></a>1.3 设置WSL的默认版本</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">wsl --set-default-version 2</span><br></pre></td></tr></table></figure>



<h2 id="1-4-查看有效分发列表"><a href="#1-4-查看有效分发列表" class="headerlink" title="1.4 查看有效分发列表"></a>1.4 查看有效分发列表</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">wsl -l -o</span><br></pre></td></tr></table></figure>



<h2 id="1-5-安装指定分发版本的Linux系统"><a href="#1-5-安装指定分发版本的Linux系统" class="headerlink" title="1.5 安装指定分发版本的Linux系统"></a>1.5 安装指定分发版本的Linux系统</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">wsl.exe --install &lt;Distribution Name&gt;</span><br></pre></td></tr></table></figure>

<p>输入安装完毕后会要求输入<strong>用户名</strong>、设置<strong>密码</strong>及确认</p>
<h2 id="1-6-更换镜像源"><a href="#1-6-更换镜像源" class="headerlink" title="1.6 更换镜像源"></a>1.6 更换镜像源</h2><p>首先访问配置文件并输入ggdg并回车清空文本内容，然后访问并更换为<a target="_blank" rel="noopener" href="https://mirrors.tuna.tsinghua.edu.cn/help/ubuntu/">清华源</a></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo vim /etc/apt/sources.list</span><br></pre></td></tr></table></figure>

<p>设置清华源时候进行如下设置：</p>
<ol>
<li>是否使用HTTPS勾选<strong>是</strong></li>
<li>是否使用sudo勾选<strong>是</strong></li>
<li>Ubuntu版本选择安装的版本，如：Ubuntu-22.04 LTS</li>
<li>启用源码源勾选<strong>是</strong></li>
<li>启用proposed勾选<strong>否</strong></li>
<li>启用源码镜像勾选<strong>是</strong></li>
</ol>
<p>然后更新源</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo apt update</span><br></pre></td></tr></table></figure>



<h2 id="1-7-WSL下的Linux卸载"><a href="#1-7-WSL下的Linux卸载" class="headerlink" title="1.7 WSL下的Linux卸载"></a>1.7 WSL下的Linux卸载</h2><p>首先查看WSL下安装的Linux系统版本</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">wsl --list</span><br></pre></td></tr></table></figure>

<p>然后选择需要删除卸载的Linux系统版本</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">wsl --unregister &lt;Distribution Name&gt;</span><br></pre></td></tr></table></figure>

<h2 id="1-8-更改WSL默认登录用户"><a href="#1-8-更改WSL默认登录用户" class="headerlink" title="1.8 更改WSL默认登录用户"></a>1.8 更改WSL默认登录用户</h2><ol>
<li>首先关闭WSL子系统</li>
</ol>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">wsl --shutdown</span><br></pre></td></tr></table></figure>

<ol start="2">
<li>然后设置登录默认用户</li>
</ol>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">&lt;Distribution Name&gt; config --default-user &lt;Username&gt; <span class="comment"># 如Ubuntu2204.exe</span></span><br><span class="line"><span class="comment"># Ubuntu2004.exe config --default-user dustwind</span></span><br></pre></td></tr></table></figure>

<h2 id="1-9-更改WSL子系统安装盘符"><a href="#1-9-更改WSL子系统安装盘符" class="headerlink" title="1.9 更改WSL子系统安装盘符"></a>1.9 更改WSL子系统安装盘符</h2><p>由于WSL子系统默认安装在C盘下，然而受限于C盘本身容量过小或者是C盘安装软件过多，则有将WSL子系统安装到其他盘的需求。</p>
<ol>
<li>首先查看WSL分发版本</li>
</ol>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">wsl -l --all -v</span><br></pre></td></tr></table></figure>

<ol start="2">
<li>然后将分发版系统打包导出到指定盘</li>
</ol>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">wsl --<span class="built_in">export</span> &lt;Distribution Name&gt; &lt;Destination Path&gt;</span><br><span class="line"><span class="comment"># 举例如下：</span></span><br><span class="line"><span class="comment"># wsl --export Ubuntu-20.04 F:\wsl-ubuntu20.04.tar</span></span><br></pre></td></tr></table></figure>

<ol start="3">
<li>注销当前分发版本</li>
</ol>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">wsl --unregister &lt;Distribution Name&gt;  <span class="comment"># 如 Ubuntu-22.04</span></span><br></pre></td></tr></table></figure>

<ol start="4">
<li>在另一个盘重新导入分发版本</li>
</ol>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">wsl --import &lt;Distribution Name&gt; &lt;Destination Path&gt; &lt;Unzip File&gt; --version 2</span><br><span class="line"><span class="comment"># 举例如下：</span></span><br><span class="line"><span class="comment"># wsl --import Ubuntu-20.04 F:\wsl-ubuntu20.04 F:\wsl-ubuntu20.04.tar --version 2</span></span><br></pre></td></tr></table></figure>

<ol start="5">
<li><p>设置默认登陆用户为安装时用户名可参考 <strong>1.8</strong> 小节所示</p>
</li>
<li><p>删除打包文件</p>
</li>
</ol>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">del &lt;FileName&gt; <span class="comment"># 可以加入绝对路径</span></span><br><span class="line"><span class="comment"># 举例如下：</span></span><br><span class="line"><span class="comment"># del F:\wsl-ubuntu22.04.tar</span></span><br></pre></td></tr></table></figure>



<blockquote>
<p><strong>注</strong></p>
<ol>
<li><p>不知道shell参数可使用 wsl –help 命令查看使用</p>
</li>
<li><p>更详细WSL常用命令汇总可参照：<a target="_blank" rel="noopener" href="https://blog.csdn.net/penngo/article/details/129951281?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522170229523816800225597067%2522%252C%2522scm%2522%253A%252220140713.130102334..%2522%257D&request_id=170229523816800225597067&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~all~sobaiduend~default-1-129951281-null-null.142%5Ev96%5Econtrol&utm_term=wsl%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4&spm=1018.2226.3001.4187">WSL 的基本命令</a></p>
</li>
</ol>
</blockquote>
<h1 id="二-WSL2中安装Linux桌面环境"><a href="#二-WSL2中安装Linux桌面环境" class="headerlink" title="二.WSL2中安装Linux桌面环境"></a>二.WSL2中安装Linux桌面环境</h1><p>桌面安装提供如下两种方式，首选第一个安装方式</p>
<ol>
<li><p><a target="_blank" rel="noopener" href="https://blog.csdn.net/weixin_44478077/article/details/128723158?spm=1001.2014.3001.5506">WSL2 Ubuntu+gnome图形界面的安装血泪史（亲测有效）</a></p>
</li>
<li><p><a target="_blank" rel="noopener" href="https://blog.csdn.net/m0_51194302/article/details/127891929?spm=1001.2014.3001.5506">wsl安装ubuntu并设置gnome图形界面详细步骤（win11+ubuntu18）</a></p>
</li>
</ol>

      

      
    </div>
    <div class="article-info article-info-index">
      
      
	<div class="article-tag tagcloud">
		<i class="icon-price-tags icon"></i>
		<ul class="article-tag-list">
			 
        		<li class="article-tag-list-item">
        			<a href="javascript:void(0)" class="js-tag article-tag-list-link color1">Linux</a>
        		</li>
      		 
        		<li class="article-tag-list-item">
        			<a href="javascript:void(0)" class="js-tag article-tag-list-link color4">WSL</a>
        		</li>
      		 
        		<li class="article-tag-list-item">
        			<a href="javascript:void(0)" class="js-tag article-tag-list-link color3">Windows</a>
        		</li>
      		
		</ul>
	</div>

      

      
        <p class="article-more-link">
          <a class="article-more-a" href="/2023/11/15/Win11%E7%8E%AF%E5%A2%83%E4%B8%8BWSL2%E7%9A%84%E5%AD%90%E7%B3%BB%E7%BB%9F%E9%83%A8%E7%BD%B2/">展开全文 >></a>
        </p>
      

      
      <div class="clearfix"></div>
    </div>
  </div>
</article>

<aside class="wrap-side-operation">
    <div class="mod-side-operation">
        
        <div class="jump-container" id="js-jump-container" style="display:none;">
            <a href="javascript:void(0)" class="mod-side-operation__jump-to-top">
                <i class="icon-font icon-back"></i>
            </a>
            <div id="js-jump-plan-container" class="jump-plan-container" style="top: -11px;">
                <i class="icon-font icon-plane jump-plane"></i>
            </div>
        </div>
        
        
    </div>
</aside>




  
    <article id="post-MySQL学习" class="article article-type-post  article-index" itemscope itemprop="blogPost">
  <div class="article-inner">
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/2022/08/31/MySQL%E5%AD%A6%E4%B9%A0/">MySql学习</a>
    </h1>
  

        
        <a href="/2022/08/31/MySQL%E5%AD%A6%E4%B9%A0/" class="archive-article-date">
  	<time datetime="2022-08-31T11:13:45.000Z" itemprop="datePublished"><i class="icon-calendar icon"></i>2022-08-31</time>
</a>
        
      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <h1 id="基础篇"><a href="#基础篇" class="headerlink" title="基础篇"></a>基础篇</h1><h2 id="一-通用语法及分类"><a href="#一-通用语法及分类" class="headerlink" title="一.通用语法及分类"></a>一.通用语法及分类</h2><ul>
<li>DDL（Data Definition Language）: 数据<strong>定义</strong>语言，用来定义数据库对象（数据库、表、字段）。常用的语句关键字主要包括 create、drop、alter等。</li>
<li>DML（Data Manipulation Language）: 数据<strong>操作</strong>语言，用来对数据库表中的数据进行增删改。常用的语句关键字主要包括 insert、delete、udpate等。</li>
<li>DQL（Data Query Language）: 数据<strong>查询</strong>语言，用来查询数据库中表的记录。常用的语句关键字主要包括 select、from、where等。</li>
<li>DCL（Data Control Language）: 数据<strong>控制</strong>语言，用来创建数据库用户、控制数据库的控制权限。主要的语句关键字包括 grant、revoke 等。</li>
</ul>
<h3 id="MySQL-的数据类型"><a href="#MySQL-的数据类型" class="headerlink" title="MySQL 的数据类型"></a>MySQL 的数据类型</h3><ol>
<li>数值类型</li>
</ol>
<table>
<thead>
<tr>
<th align="center">类型</th>
<th align="center">大小</th>
<th align="center">有符号范围（Signed）</th>
<th align="center">无符号范围（Unsigned）</th>
<th align="center">描述</th>
</tr>
</thead>
<tbody><tr>
<td align="center">TINYINT</td>
<td align="center">1 Byte</td>
<td align="center">(-128，127)</td>
<td align="center">(0 ，255)</td>
<td align="center">小整数值</td>
</tr>
<tr>
<td align="center">SMALLINT</td>
<td align="center">2 Bytes</td>
<td align="center">(-32768，32767)</td>
<td align="center">(0 ，65535)</td>
<td align="center">大整数值</td>
</tr>
<tr>
<td align="center">MEDIUMINT</td>
<td align="center">3 Bytes</td>
<td align="center">(-8388608，8388607)</td>
<td align="center">(0 ，16777215)</td>
<td align="center">大整数值</td>
</tr>
<tr>
<td align="center">INT或者INTEGER</td>
<td align="center">4 Bytes</td>
<td align="center">(-2147483648，2147483647)</td>
<td align="center">(0 ，4294967295)</td>
<td align="center">大整数值</td>
</tr>
<tr>
<td align="center">BIGINT</td>
<td align="center">8 Bytes</td>
<td align="center">(-2^63 ，2^63 -1)</td>
<td align="center">(0，2^64-1)</td>
<td align="center">极大整数值</td>
</tr>
<tr>
<td align="center">FLOAT</td>
<td align="center">4 Bytes</td>
<td align="center">(-3.402823466 E+38，3.402823466351 E+38)</td>
<td align="center">0 和 (1.175494351 E-38，3.402823466351 E+38)</td>
<td align="center">单精度浮点数值</td>
</tr>
<tr>
<td align="center">DOUBLE</td>
<td align="center">8 Bytes</td>
<td align="center">(-1.7976931348623157 E+308 ，1.7976931348623157 E+308)</td>
<td align="center">0 和 (2.2250738585072014 E-308 ，1.7976931348623157 E+308)</td>
<td align="center">双精度浮点数值</td>
</tr>
<tr>
<td align="center">DECIMAL</td>
<td align="center">——</td>
<td align="center">依赖于精度（M）和标度（D）的数值</td>
<td align="center">依赖于精度（M）和标度（D）的数值</td>
<td align="center">小数值（精确定点数）</td>
</tr>
</tbody></table>
<ol start="2">
<li>字符串类型</li>
</ol>
<table>
<thead>
<tr>
<th align="center">类型</th>
<th align="center">大小</th>
<th align="center">描述</th>
</tr>
</thead>
<tbody><tr>
<td align="center">CHAR</td>
<td align="center">0 - 255 Bytes</td>
<td align="center">变长字符串</td>
</tr>
<tr>
<td align="center">VARCHAR</td>
<td align="center">0 - 65535 Bytes</td>
<td align="center">定长字符串</td>
</tr>
<tr>
<td align="center">TINYBLOB</td>
<td align="center">0 - 255 Bytes</td>
<td align="center">不超过255个字符的二进制数据</td>
</tr>
<tr>
<td align="center">TINYTEXT</td>
<td align="center">0 - 255 Bytes</td>
<td align="center">短文本字符串</td>
</tr>
<tr>
<td align="center">BLOB</td>
<td align="center">0 - 65535 Bytes</td>
<td align="center">二进制形式的长文本数据</td>
</tr>
<tr>
<td align="center">TEXT</td>
<td align="center">0 - 65535 Bytes</td>
<td align="center">长文本数据</td>
</tr>
<tr>
<td align="center">MEDIUMBLOB</td>
<td align="center">0 - 16777215 Bytes</td>
<td align="center">二进制形式的中等长度文本数据</td>
</tr>
<tr>
<td align="center">MEDIUMTEXT</td>
<td align="center">0 - 16777215 Bytes</td>
<td align="center">中等长度文本数据</td>
</tr>
<tr>
<td align="center">LONGBLOB</td>
<td align="center">0 - 4294967295 Bytes</td>
<td align="center">二进制形式的极大文本数据</td>
</tr>
<tr>
<td align="center">LONGTEXT</td>
<td align="center">0 - 4294967295 Bytes</td>
<td align="center">极大文本数据</td>
</tr>
</tbody></table>
<ol start="3">
<li>日期类型</li>
</ol>
<table>
<thead>
<tr>
<th align="center">类型</th>
<th align="center">大小</th>
<th align="center">范围</th>
<th align="center">格式</th>
<th align="center">描述</th>
</tr>
</thead>
<tbody><tr>
<td align="center">DATE</td>
<td align="center">3 Bytes</td>
<td align="center">1000-01-01 到 9999-12-31</td>
<td align="center">YYYY-MM-DD</td>
<td align="center">日期值</td>
</tr>
<tr>
<td align="center">TIME</td>
<td align="center">3 Bytes</td>
<td align="center">-838:59:59 到 838:59:59</td>
<td align="center">HH:MM:SS</td>
<td align="center">时间值或者持续时间</td>
</tr>
<tr>
<td align="center">YEAR</td>
<td align="center">1 Bytes</td>
<td align="center">1901 到 2155</td>
<td align="center">YYYY</td>
<td align="center">年份值</td>
</tr>
<tr>
<td align="center">DATETIME</td>
<td align="center">8 Bytes</td>
<td align="center">1000-01-01 00:00:00 到 9999-12-31 23:59:59</td>
<td align="center">YYYY-MM-DD HH:MM:SS</td>
<td align="center">混合日期和时间值</td>
</tr>
<tr>
<td align="center">TIMESTAMP</td>
<td align="center">4 Bytes</td>
<td align="center">1970-01-01 00:00:00 到 2038-01-19 03:14:07</td>
<td align="center">YYYY-MM-DD HH:MM:SS</td>
<td align="center">混合日期和时间值。时间戳</td>
</tr>
</tbody></table>
<h3 id="1-1-DDL（数据定义语言）"><a href="#1-1-DDL（数据定义语言）" class="headerlink" title="1.1 DDL（数据定义语言）"></a>1.1 DDL（数据定义语言）</h3><p>数据定义语言</p>
<h4 id="1-1-1-数据库操作"><a href="#1-1-1-数据库操作" class="headerlink" title="1.1.1 数据库操作"></a>1.1.1 数据库操作</h4><ul>
<li><p>查询所有数据库：<br><code>SHOW DATABASES;</code></p>
</li>
<li><p>查询当前数据库：<br><code>SELECT DATABASE();</code></p>
</li>
<li><p>创建数据库：<br><code>CREATE DATABASE [ IF NOT EXISTS ] 数据库名 [ DEFAULT CHARSET 字符集] [COLLATE 排序规则 ];</code></p>
</li>
<li><p>删除数据库：<br><code>DROP DATABASE [ IF EXISTS ] 数据库名;</code></p>
</li>
<li><p>使用数据库：<br><code>USE 数据库名;</code></p>
</li>
</ul>
<blockquote>
<p>注：UTF8字符集长度为3字节，有些符号占4字节，所以一般推荐用utf8mb4字符集</p>
</blockquote>
<h4 id="1-1-2-表操作"><a href="#1-1-2-表操作" class="headerlink" title="1.1.2 表操作"></a>1.1.2 表操作</h4><ul>
<li><p>查询当前数据库所有表：</p>
<p><code>SHOW TABLES;</code></p>
</li>
<li><p>查询表结构：<br><code>DESC 表名;</code></p>
</li>
<li><p>查询指定表的建表语句：<br><code>SHOW CREATE TABLE 表名;</code></p>
</li>
<li><p>创建表：</p>
</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">CREATE TABLE 表名(</span><br><span class="line">	字段1 字段1类型 [COMMENT 字段1注释],</span><br><span class="line">	字段2 字段2类型 [COMMENT 字段2注释],</span><br><span class="line">	字段3 字段3类型 [COMMENT 字段3注释],</span><br><span class="line">	...</span><br><span class="line">	字段n 字段n类型 [COMMENT 字段n注释]</span><br><span class="line">)[ COMMENT 表注释 ];</span><br></pre></td></tr></table></figure>
<blockquote>
<p>注： <strong>最后一个字段后面没有逗号</strong></p>
</blockquote>
<ul>
<li><p>添加字段：<br><code>ALTER TABLE 表名 ADD 字段名 类型(长度) [COMMENT 注释] [约束];</code><br>例：<code>ALTER TABLE emp ADD nickname varchar(20) COMMENT &#39;昵称&#39;;</code></p>
</li>
<li><p>修改数据类型：<br><code>ALTER TABLE 表名 MODIFY 字段名 新数据类型(长度);</code></p>
</li>
<li><p>修改字段名和字段类型：<br><code>ALTER TABLE 表名 CHANGE 旧字段名 新字段名 类型(长度) [COMMENT 注释] [约束];</code><br>例：将emp表的nickname字段修改为username，类型为varchar(30)<br><code>ALTER TABLE emp CHANGE nickname username varchar(30) COMMENT &#39;昵称&#39;;</code></p>
</li>
<li><p>删除字段：<br><code>ALTER TABLE 表名 DROP 字段名;</code></p>
</li>
<li><p>修改表名：<br><code>ALTER TABLE 表名 RENAME TO 新表名</code></p>
</li>
<li><p>删除表：<br><code>DROP TABLE [IF EXISTS] 表名;</code></p>
</li>
<li><p>删除表，并重新创建该表：<br><code>TRUNCATE TABLE 表名;</code></p>
</li>
</ul>
<h3 id="1-2-DML（数据操作语言）"><a href="#1-2-DML（数据操作语言）" class="headerlink" title="1.2 DML（数据操作语言）"></a>1.2 DML（数据操作语言）</h3><h4 id="1-2-1-添加数据"><a href="#1-2-1-添加数据" class="headerlink" title="1.2.1 添加数据"></a>1.2.1 添加数据</h4><ul>
<li><p>指定字段：<br><code>INSERT INTO 表名 (字段名1, 字段名2, ...) VALUES (值1, 值2, ...);</code></p>
</li>
<li><p>全部字段：<br><code>INSERT INTO 表名 VALUES (值1, 值2, ...);</code></p>
</li>
<li><p>批量添加数据：<br><code>INSERT INTO 表名 (字段名1, 字段名2, ...) VALUES (值1, 值2, ...), (值1, 值2, ...), (值1, 值2, ...);</code><br><code>INSERT INTO 表名 VALUES (值1, 值2, ...), (值1, 值2, ...), (值1, 值2, ...);</code></p>
</li>
</ul>
<blockquote>
<p><strong>注意事项</strong>：</p>
<ul>
<li>插入数据时，指定字段顺序需要与值的顺序一一对应</li>
<li>字符串和日期类型数据应该包含在引号中</li>
<li>插入的数据大小应该在字段的规定范围内</li>
</ul>
</blockquote>
<h4 id="1-2-2-更新和删除数据"><a href="#1-2-2-更新和删除数据" class="headerlink" title="1.2.2 更新和删除数据"></a>1.2.2 更新和删除数据</h4><ul>
<li><p>修改数据：<br><code>UPDATE 表名 SET 字段名1 = 值1, 字段名2 = 值2, ... [ WHERE 条件 ];</code><br>例：<br><code>UPDATE emp SET name = &#39;Jack&#39; WHERE id = 1;</code></p>
</li>
<li><p>删除数据：<br><code>DELETE FROM 表名 [ WHERE 条件 ];</code></p>
</li>
</ul>
<h3 id="1-3-DQL（数据查询语言）"><a href="#1-3-DQL（数据查询语言）" class="headerlink" title="1.3 DQL（数据查询语言）"></a>1.3 DQL（数据查询语言）</h3><ul>
<li>语法：</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line">SELECT</span><br><span class="line">	字段列表</span><br><span class="line">FROM</span><br><span class="line">	表名字段</span><br><span class="line">WHERE</span><br><span class="line">	条件列表</span><br><span class="line">GROUP BY</span><br><span class="line">	分组字段列表</span><br><span class="line">HAVING</span><br><span class="line">	分组后的条件列表</span><br><span class="line">ORDER BY</span><br><span class="line">	排序字段列表</span><br><span class="line">LIMIT</span><br><span class="line">	分页参数</span><br></pre></td></tr></table></figure>

<h4 id="1-3-1-基础查询"><a href="#1-3-1-基础查询" class="headerlink" title="1.3.1 基础查询"></a>1.3.1 基础查询</h4><ul>
<li><p>查询多个字段：<br><code>SELECT 字段1, 字段2, 字段3, ... FROM 表名;</code><br><code>SELECT * FROM 表名;</code></p>
</li>
<li><p>设置别名：<br><code>SELECT 字段1 [ AS 别名1 ], 字段2 [ AS 别名2 ], 字段3 [ AS 别名3 ], ... FROM 表名;</code><br><code>SELECT 字段1 [ 别名1 ], 字段2 [ 别名2 ], 字段3 [ 别名3 ], ... FROM 表名;</code></p>
</li>
<li><p>去除重复记录：<br><code>SELECT DISTINCT 字段列表 FROM 表名;</code></p>
</li>
<li><p>转义：<br><code>SELECT * FROM 表名 WHERE name LIKE &#39;/_张三&#39; ESCAPE &#39;/&#39;</code><br>&#x2F; 之后的_不作为通配符</p>
</li>
</ul>
<h4 id="1-3-2-条件查询"><a href="#1-3-2-条件查询" class="headerlink" title="1.3.2 条件查询"></a>1.3.2 条件查询</h4><ul>
<li>语法：<br><code>SELECT 字段列表 FROM 表名 WHERE 条件列表;</code></li>
</ul>
<p>条件：</p>
<table>
<thead>
<tr>
<th align="center">比较运算符</th>
<th align="center">功能</th>
</tr>
</thead>
<tbody><tr>
<td align="center">&gt;</td>
<td align="center">大于</td>
</tr>
<tr>
<td align="center">&gt;&#x3D;</td>
<td align="center">大于等于</td>
</tr>
<tr>
<td align="center">&lt;</td>
<td align="center">小于</td>
</tr>
<tr>
<td align="center">&lt;&#x3D;</td>
<td align="center">小于等于</td>
</tr>
<tr>
<td align="center">&#x3D;</td>
<td align="center">等于</td>
</tr>
<tr>
<td align="center">&lt;&gt; 或 !&#x3D;</td>
<td align="center">不等于</td>
</tr>
<tr>
<td align="center">BETWEEN … AND …</td>
<td align="center">在某个范围内（含最小、最大值）</td>
</tr>
<tr>
<td align="center">IN(…)</td>
<td align="center">在in之后的列表中的值，多选一</td>
</tr>
<tr>
<td align="center">LIKE 占位符</td>
<td align="center">模糊匹配（_匹配单个字符，%匹配任意个字符）</td>
</tr>
<tr>
<td align="center">IS NULL</td>
<td align="center">是NULL</td>
</tr>
</tbody></table>
<table>
<thead>
<tr>
<th align="center">逻辑运算符</th>
<th align="center">功能</th>
</tr>
</thead>
<tbody><tr>
<td align="center">AND 或 &amp;&amp;</td>
<td align="center">并且（多个条件同时成立）</td>
</tr>
<tr>
<td align="center">OR 或 &#124;&#124;</td>
<td align="center">或者（多个条件任意一个成立）</td>
</tr>
<tr>
<td align="center">NOT 或 !</td>
<td align="center">非，不是</td>
</tr>
</tbody></table>
<p>例子：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br></pre></td><td class="code"><pre><span class="line">-- 年龄等于30</span><br><span class="line">select * from employee where age = 30;</span><br><span class="line">-- 年龄小于30</span><br><span class="line">select * from employee where age &lt; 30;</span><br><span class="line">-- 小于等于</span><br><span class="line">select * from employee where age &lt;= 30;</span><br><span class="line">-- 没有身份证</span><br><span class="line">select * from employee where idcard is null or idcard = &#x27;&#x27;;</span><br><span class="line">-- 有身份证</span><br><span class="line">select * from employee where idcard;</span><br><span class="line">select * from employee where idcard is not null;</span><br><span class="line">-- 不等于</span><br><span class="line">select * from employee where age != 30;</span><br><span class="line">-- 年龄在20到30之间</span><br><span class="line">select * from employee where age between 20 and 30;</span><br><span class="line">select * from employee where age &gt;= 20 and age &lt;= 30;</span><br><span class="line">-- 下面语句不报错，但查不到任何信息</span><br><span class="line">select * from employee where age between 30 and 20;</span><br><span class="line">-- 性别为女且年龄小于30</span><br><span class="line">select * from employee where age &lt; 30 and gender = &#x27;女&#x27;;</span><br><span class="line">-- 年龄等于25或30或35</span><br><span class="line">select * from employee where age = 25 or age = 30 or age = 35;</span><br><span class="line">select * from employee where age in (25, 30, 35);</span><br><span class="line">-- 姓名为两个字</span><br><span class="line">select * from employee where name like &#x27;__&#x27;;</span><br><span class="line">-- 身份证最后为X</span><br><span class="line">select * from employee where idcard like &#x27;%X&#x27;;</span><br></pre></td></tr></table></figure>

<h4 id="1-3-3-聚合查询（聚合函数）"><a href="#1-3-3-聚合查询（聚合函数）" class="headerlink" title="1.3.3 聚合查询（聚合函数）"></a>1.3.3 聚合查询（聚合函数）</h4><p>常见聚合函数：</p>
<table>
<thead>
<tr>
<th align="center">函数</th>
<th align="center">功能</th>
</tr>
</thead>
<tbody><tr>
<td align="center">count</td>
<td align="center">统计数量</td>
</tr>
<tr>
<td align="center">max</td>
<td align="center">最大值</td>
</tr>
<tr>
<td align="center">min</td>
<td align="center">最小值</td>
</tr>
<tr>
<td align="center">avg</td>
<td align="center">平均值</td>
</tr>
<tr>
<td align="center">sum</td>
<td align="center">求和</td>
</tr>
</tbody></table>
<ul>
<li>语法：<br><code>SELECT 聚合函数(字段列表) FROM 表名;</code><br>例：<br><code>SELECT count(id) from employee where workaddress = &quot;广东省&quot;;</code></li>
</ul>
<h4 id="1-3-4-分组查询"><a href="#1-3-4-分组查询" class="headerlink" title="1.3.4 分组查询"></a>1.3.4 分组查询</h4><ul>
<li>语法：<br><code>SELECT 字段列表 FROM 表名 [ WHERE 条件 ] GROUP BY 分组字段名 [ HAVING 分组后的过滤条件 ];</code></li>
</ul>
<p>where 和 having 的区别：</p>
<ul>
<li>执行时机不同：where是分组之前进行过滤，不满足where条件不参与分组；having是分组后对结果进行过滤。</li>
<li>判断条件不同：where不能对聚合函数进行判断，而having可以。</li>
</ul>
<p>例子：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">-- 根据性别分组，统计男性和女性数量（只显示分组数量，不显示哪个是男哪个是女）</span><br><span class="line">select count(*) from employee group by gender;</span><br><span class="line">-- 根据性别分组，统计男性和女性数量</span><br><span class="line">select gender, count(*) from employee group by gender;</span><br><span class="line">-- 根据性别分组，统计男性和女性的平均年龄</span><br><span class="line">select gender, avg(age) from employee group by gender;</span><br><span class="line">-- 年龄小于45，并根据工作地址分组</span><br><span class="line">select workaddress, count(*) from employee where age &lt; 45 group by workaddress;</span><br><span class="line">-- 年龄小于45，并根据工作地址分组，获取员工数量大于等于3的工作地址</span><br><span class="line">select workaddress, count(*) address_count from employee where age &lt; 45 group by workaddress having address_count &gt;= 3;</span><br></pre></td></tr></table></figure>

<h5 id="注意事项"><a href="#注意事项" class="headerlink" title="注意事项"></a>注意事项</h5><ul>
<li>执行顺序：where &gt; 聚合函数 &gt; having</li>
<li>分组之后，查询的字段一般为聚合函数和分组字段，查询其他字段无任何意义</li>
</ul>
<h4 id="1-3-5-排序查询"><a href="#1-3-5-排序查询" class="headerlink" title="1.3.5 排序查询"></a>1.3.5 排序查询</h4><ul>
<li>语法：<br><code>SELECT 字段列表 FROM 表名 ORDER BY 字段1 排序方式1, 字段2 排序方式2;</code></li>
</ul>
<p>排序方式：</p>
<ul>
<li>ASC: 升序（默认）</li>
<li>DESC: 降序</li>
</ul>
<p>例子：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">-- 根据年龄升序排序</span><br><span class="line">SELECT * FROM employee ORDER BY age ASC;</span><br><span class="line">SELECT * FROM employee ORDER BY age;</span><br><span class="line">-- 两字段排序，根据年龄升序排序，入职时间降序排序</span><br><span class="line">SELECT * FROM employee ORDER BY age ASC, entrydate DESC;</span><br></pre></td></tr></table></figure>

<blockquote>
<p>注意：如果是多字段排序，当第一个字段值相同时，才会根据第二个字段进行排序</p>
</blockquote>
<h4 id="1-3-6-分页查询"><a href="#1-3-6-分页查询" class="headerlink" title="1.3.6 分页查询"></a>1.3.6 分页查询</h4><ul>
<li>语法：<br><code>SELECT 字段列表 FROM 表名 LIMIT 起始索引, 查询记录数;</code></li>
</ul>
<p>例子：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">-- 查询第一页数据，展示10条</span><br><span class="line">SELECT * FROM employee LIMIT 0, 10;</span><br><span class="line">-- 查询第二页</span><br><span class="line">SELECT * FROM employee LIMIT 10, 10;</span><br></pre></td></tr></table></figure>

<blockquote>
<p>注意事项：</p>
<ul>
<li>起始索引从0开始，起始索引 &#x3D; （查询页码 - 1） * 每页显示记录数</li>
<li>分页查询是数据库的方言，不同数据库有不同实现，MySQL是LIMIT</li>
<li>如果查询的是第一页数据，起始索引可以省略，直接简写 LIMIT 10</li>
</ul>
</blockquote>
<h4 id="1-3-7-DQL执行顺序"><a href="#1-3-7-DQL执行顺序" class="headerlink" title="1.3.7 DQL执行顺序"></a>1.3.7 DQL执行顺序</h4><p>FROM -&gt; WHERE -&gt; GROUP BY -&gt; SELECT -&gt; ORDER BY -&gt; LIMIT</p>
<h3 id="1-4-DCL（数据控制语言）"><a href="#1-4-DCL（数据控制语言）" class="headerlink" title="1.4 DCL（数据控制语言）"></a>1.4 DCL（数据控制语言）</h3><h4 id="1-4-1-管理用户"><a href="#1-4-1-管理用户" class="headerlink" title="1.4.1 管理用户"></a>1.4.1 管理用户</h4><ul>
<li>查询用户：</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">USE mysql;</span><br><span class="line">SELECT * FROM user;</span><br></pre></td></tr></table></figure>

<ul>
<li><p>创建用户:<br><code>CREATE USER &#39;用户名&#39;@&#39;主机名&#39; IDENTIFIED BY &#39;密码&#39;;</code></p>
</li>
<li><p>修改用户密码：<br><code>ALTER USER &#39;用户名&#39;@&#39;主机名&#39; IDENTIFIED WITH mysql_native_password BY &#39;新密码&#39;;</code></p>
</li>
<li><p>删除用户：<br><code>DROP USER &#39;用户名&#39;@&#39;主机名&#39;;</code></p>
</li>
</ul>
<p>例子：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">-- 创建用户test，只能在当前主机localhost访问</span><br><span class="line">create user &#x27;test&#x27;@&#x27;localhost&#x27; identified by &#x27;123456&#x27;;</span><br><span class="line">-- 创建用户test，能在任意主机访问</span><br><span class="line">create user &#x27;test&#x27;@&#x27;%&#x27; identified by &#x27;123456&#x27;;</span><br><span class="line">create user &#x27;test&#x27; identified by &#x27;123456&#x27;;</span><br><span class="line">-- 修改密码</span><br><span class="line">alter user &#x27;test&#x27;@&#x27;localhost&#x27; identified with mysql_native_password by &#x27;1234&#x27;;</span><br><span class="line">-- 删除用户</span><br><span class="line">drop user &#x27;test&#x27;@&#x27;localhost&#x27;;</span><br></pre></td></tr></table></figure>

<blockquote>
<p>注意事项：主机名可以使用 % 通配</p>
</blockquote>
<h4 id="1-4-2-权限控制"><a href="#1-4-2-权限控制" class="headerlink" title="1.4.2 权限控制"></a>1.4.2 权限控制</h4><ul>
<li>常用权限：</li>
</ul>
<table>
<thead>
<tr>
<th align="center">权限</th>
<th align="center">说明</th>
</tr>
</thead>
<tbody><tr>
<td align="center">ALL, ALL PRIVILEGES</td>
<td align="center">所有权限</td>
</tr>
<tr>
<td align="center">SELECT</td>
<td align="center">查询数据</td>
</tr>
<tr>
<td align="center">INSERT</td>
<td align="center">插入数据</td>
</tr>
<tr>
<td align="center">UPDATE</td>
<td align="center">修改数据</td>
</tr>
<tr>
<td align="center">DELETE</td>
<td align="center">删除数据</td>
</tr>
<tr>
<td align="center">ALTER</td>
<td align="center">修改表</td>
</tr>
<tr>
<td align="center">DROP</td>
<td align="center">删除数据库&#x2F;表&#x2F;视图</td>
</tr>
<tr>
<td align="center">CREATE</td>
<td align="center">创建数据库&#x2F;表</td>
</tr>
</tbody></table>
<p>更多权限请看<a href="#%E6%9D%83%E9%99%90%E4%B8%80%E8%A7%88%E8%A1%A8" title="权限一览表">权限一览表</a></p>
<ul>
<li><p>查询权限：<br><code>SHOW GRANTS FOR &#39;用户名&#39;@&#39;主机名&#39;;</code></p>
</li>
<li><p>授予权限：<br><code>GRANT 权限列表 ON 数据库名.表名 TO &#39;用户名&#39;@&#39;主机名&#39;;</code></p>
</li>
<li><p>撤销权限：<br><code>REVOKE 权限列表 ON 数据库名.表名 FROM &#39;用户名&#39;@&#39;主机名&#39;;</code></p>
</li>
</ul>
<h5 id="注意事项-1"><a href="#注意事项-1" class="headerlink" title="注意事项"></a>注意事项</h5><ul>
<li>多个权限用逗号分隔</li>
<li>授权时，数据库名和表名可以用 * 进行通配，代表所有</li>
</ul>
<h2 id="二-函数"><a href="#二-函数" class="headerlink" title="二.函数"></a>二.函数</h2><ul>
<li>字符串函数</li>
<li>数值函数</li>
<li>日期函数</li>
<li>流程函数</li>
</ul>
<h3 id="2-1-字符串函数"><a href="#2-1-字符串函数" class="headerlink" title="2.1 字符串函数"></a>2.1 字符串函数</h3><ul>
<li>常用函数：</li>
</ul>
<table>
<thead>
<tr>
<th align="center">函数</th>
<th align="center">功能</th>
</tr>
</thead>
<tbody><tr>
<td align="center">CONCAT(s1, s2, …, sn)</td>
<td align="center">字符串拼接，将s1, s2, …, sn拼接成一个字符串</td>
</tr>
<tr>
<td align="center">LOWER(str)</td>
<td align="center">将字符串全部转为小写</td>
</tr>
<tr>
<td align="center">UPPER(str)</td>
<td align="center">将字符串全部转为大写</td>
</tr>
<tr>
<td align="center">LPAD(str, n, pad)</td>
<td align="center">左填充，用字符串pad对str的左边进行填充，达到n个字符串长度</td>
</tr>
<tr>
<td align="center">RPAD(str, n, pad)</td>
<td align="center">右填充，用字符串pad对str的右边进行填充，达到n个字符串长度</td>
</tr>
<tr>
<td align="center">TRIM(str)</td>
<td align="center">去掉字符串头部和尾部的空格</td>
</tr>
<tr>
<td align="center">SUBSTRING(str, start, len)</td>
<td align="center">返回从字符串str从start位置起的len个长度的字符串</td>
</tr>
</tbody></table>
<p>使用示例：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line">-- 拼接</span><br><span class="line">SELECT CONCAT(&#x27;Hello&#x27;, &#x27;World&#x27;);</span><br><span class="line">-- 小写</span><br><span class="line">SELECT LOWER(&#x27;Hello&#x27;);</span><br><span class="line">-- 大写</span><br><span class="line">SELECT UPPER(&#x27;Hello&#x27;);</span><br><span class="line">-- 左填充</span><br><span class="line">SELECT LPAD(&#x27;01&#x27;, 5, &#x27;-&#x27;);</span><br><span class="line">-- 右填充</span><br><span class="line">SELECT RPAD(&#x27;01&#x27;, 5, &#x27;-&#x27;);</span><br><span class="line">-- 去除空格</span><br><span class="line">SELECT TRIM(&#x27; Hello World &#x27;);</span><br><span class="line">-- 切片（起始索引为1）</span><br><span class="line">SELECT SUBSTRING(&#x27;Hello World&#x27;, 1, 5);</span><br></pre></td></tr></table></figure>

<h3 id="2-2-数值函数"><a href="#2-2-数值函数" class="headerlink" title="2.2 数值函数"></a>2.2 数值函数</h3><ul>
<li>常见函数：</li>
</ul>
<table>
<thead>
<tr>
<th align="center">函数</th>
<th align="center">功能</th>
</tr>
</thead>
<tbody><tr>
<td align="center">CEIL(x)</td>
<td align="center">向上取整</td>
</tr>
<tr>
<td align="center">FLOOR(x)</td>
<td align="center">向下取整</td>
</tr>
<tr>
<td align="center">MOD(x, y)</td>
<td align="center">返回x&#x2F;y的模</td>
</tr>
<tr>
<td align="center">RAND()</td>
<td align="center">返回0~1内的随机数</td>
</tr>
<tr>
<td align="center">ROUND(x, y)</td>
<td align="center">求参数x的四舍五入值，保留y位小数</td>
</tr>
</tbody></table>
<h3 id="2-3-日期函数"><a href="#2-3-日期函数" class="headerlink" title="2.3 日期函数"></a>2.3 日期函数</h3><ul>
<li>常用函数：</li>
</ul>
<table>
<thead>
<tr>
<th align="center">函数</th>
<th align="center">功能</th>
</tr>
</thead>
<tbody><tr>
<td align="center">CURDATE()</td>
<td align="center">返回当前日期</td>
</tr>
<tr>
<td align="center">CURTIME()</td>
<td align="center">返回当前时间</td>
</tr>
<tr>
<td align="center">NOW()</td>
<td align="center">返回当前日期和时间</td>
</tr>
<tr>
<td align="center">YEAR(date)</td>
<td align="center">获取指定date的年份</td>
</tr>
<tr>
<td align="center">MONTH(date)</td>
<td align="center">获取指定date的月份</td>
</tr>
<tr>
<td align="center">DAY(date)</td>
<td align="center">获取指定date的日期</td>
</tr>
<tr>
<td align="center">DATE_ADD(date, INTERVAL expr type)</td>
<td align="center">返回一个日期&#x2F;时间值加上一个时间间隔expr后的时间值</td>
</tr>
<tr>
<td align="center">DATEDIFF(date1, date2)</td>
<td align="center">返回起始时间date1和结束时间date2之间的天数</td>
</tr>
</tbody></table>
<p>例子：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">-- DATE_ADD</span><br><span class="line">SELECT DATE_ADD(NOW(), INTERVAL 70 YEAR);</span><br></pre></td></tr></table></figure>

<h3 id="2-4-流程函数"><a href="#2-4-流程函数" class="headerlink" title="2.4 流程函数"></a>2.4 流程函数</h3><ul>
<li>常用函数：</li>
</ul>
<table>
<thead>
<tr>
<th align="center">函数</th>
<th align="center">功能</th>
</tr>
</thead>
<tbody><tr>
<td align="center">IF(value, t, f)</td>
<td align="center">如果value为true，则返回t，否则返回f</td>
</tr>
<tr>
<td align="center">IFNULL(value1, value2)</td>
<td align="center">如果value1不为空，返回value1，否则返回value2</td>
</tr>
<tr>
<td align="center">CASE WHEN [ val1 ] THEN [ res1 ] … ELSE [ default ] END</td>
<td align="center">如果val1为true，返回res1，… 否则返回default默认值</td>
</tr>
<tr>
<td align="center">CASE [ expr ] WHEN [ val1 ] THEN [ res1 ] … ELSE [ default ] END</td>
<td align="center">如果expr的值等于val1，返回res1，… 否则返回default默认值</td>
</tr>
</tbody></table>
<p>例子：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">select</span><br><span class="line">	name,</span><br><span class="line">	(case when age &gt; 30 then &#x27;中年&#x27; else &#x27;青年&#x27; end)</span><br><span class="line">from employee;</span><br><span class="line">select</span><br><span class="line">	name,</span><br><span class="line">	(case workaddress when &#x27;北京市&#x27; then &#x27;一线城市&#x27; when &#x27;上海市&#x27; then &#x27;一线城市&#x27; else &#x27;二线城市&#x27; end) as &#x27;工作地址&#x27;</span><br><span class="line">from employee;</span><br></pre></td></tr></table></figure>

<h2 id="三-约束"><a href="#三-约束" class="headerlink" title="三.约束"></a>三.约束</h2><ul>
<li>分类：</li>
</ul>
<table>
<thead>
<tr>
<th align="center">约束</th>
<th align="center">描述</th>
<th align="center">关键字</th>
</tr>
</thead>
<tbody><tr>
<td align="center">非空约束</td>
<td align="center">限制该字段的数据不能为null</td>
<td align="center">NOT NULL</td>
</tr>
<tr>
<td align="center">唯一约束</td>
<td align="center">保证该字段的所有数据都是唯一、不重复的</td>
<td align="center">UNIQUE</td>
</tr>
<tr>
<td align="center">主键约束</td>
<td align="center">主键是一行数据的唯一标识，要求非空且唯一</td>
<td align="center">PRIMARY KEY</td>
</tr>
<tr>
<td align="center">默认约束</td>
<td align="center">保存数据时，如果未指定该字段的值，则采用默认值</td>
<td align="center">DEFAULT</td>
</tr>
<tr>
<td align="center">检查约束（8.0.1版本后）</td>
<td align="center">保证字段值满足某一个条件</td>
<td align="center">CHECK</td>
</tr>
<tr>
<td align="center">外键约束</td>
<td align="center">用来让两张图的数据之间建立连接，保证数据的一致性和完整性</td>
<td align="center">FOREIGN KEY</td>
</tr>
</tbody></table>
<p>约束是作用于表中字段上的，可以再创建表&#x2F;修改表的时候添加约束。</p>
<h3 id="3-1-常用约束"><a href="#3-1-常用约束" class="headerlink" title="3.1 常用约束"></a>3.1 常用约束</h3><table>
<thead>
<tr>
<th align="center">约束条件</th>
<th align="center">关键字</th>
</tr>
</thead>
<tbody><tr>
<td align="center">主键</td>
<td align="center">PRIMARY KEY</td>
</tr>
<tr>
<td align="center">自动增长</td>
<td align="center">AUTO_INCREMENT</td>
</tr>
<tr>
<td align="center">不为空</td>
<td align="center">NOT NULL</td>
</tr>
<tr>
<td align="center">唯一</td>
<td align="center">UNIQUE</td>
</tr>
<tr>
<td align="center">逻辑条件</td>
<td align="center">CHECK</td>
</tr>
<tr>
<td align="center">默认值</td>
<td align="center">DEFAULT</td>
</tr>
</tbody></table>
<p>例子：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">create table user(</span><br><span class="line">	id int primary key auto_increment,</span><br><span class="line">	name varchar(10) not null unique,</span><br><span class="line">	age int check(age &gt; 0 and age &lt; 120),</span><br><span class="line">	status char(1) default &#x27;1&#x27;,</span><br><span class="line">	gender char(1)</span><br><span class="line">);</span><br></pre></td></tr></table></figure>

<h3 id="3-2-外键约束"><a href="#3-2-外键约束" class="headerlink" title="3.2 外键约束"></a>3.2 外键约束</h3><ul>
<li>添加外键：</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">CREATE TABLE 表名(</span><br><span class="line">	字段名 字段类型,</span><br><span class="line">	...</span><br><span class="line">	[CONSTRAINT] [外键名称] FOREIGN KEY(外键字段名) REFERENCES 主表(主表列名)</span><br><span class="line">);</span><br><span class="line">ALTER TABLE 表名 ADD CONSTRAINT 外键名称 FOREIGN KEY (外键字段名) REFERENCES 主表(主表列名);</span><br><span class="line"></span><br><span class="line">-- 例子</span><br><span class="line">alter table emp add constraint fk_emp_dept_id foreign key(dept_id) references dept(id);</span><br></pre></td></tr></table></figure>

<ul>
<li>删除外键：<br><code>ALTER TABLE 表名 DROP FOREIGN KEY 外键名;</code></li>
</ul>
<h4 id="删除-更新行为"><a href="#删除-更新行为" class="headerlink" title="删除&#x2F;更新行为"></a>删除&#x2F;更新行为</h4><table>
<thead>
<tr>
<th align="center">行为</th>
<th align="center">说明</th>
</tr>
</thead>
<tbody><tr>
<td align="center">NO ACTION</td>
<td align="center">当在父表中删除&#x2F;更新对应记录时，首先检查该记录是否有对应外键，如果有则不允许删除&#x2F;更新（与RESTRICT一致）</td>
</tr>
<tr>
<td align="center">RESTRICT</td>
<td align="center">当在父表中删除&#x2F;更新对应记录时，首先检查该记录是否有对应外键，如果有则不允许删除&#x2F;更新（与NO ACTION一致）</td>
</tr>
<tr>
<td align="center">CASCADE</td>
<td align="center">当在父表中删除&#x2F;更新对应记录时，首先检查该记录是否有对应外键，如果有则也删除&#x2F;更新外键在子表中的记录</td>
</tr>
<tr>
<td align="center">SET NULL</td>
<td align="center">当在父表中删除&#x2F;更新对应记录时，首先检查该记录是否有对应外键，如果有则设置子表中该外键值为null（要求该外键允许为null）</td>
</tr>
<tr>
<td align="center">SET DEFAULT</td>
<td align="center">父表有变更时，子表将外键设为一个默认值（Innodb不支持）</td>
</tr>
</tbody></table>
<ul>
<li>更改删除&#x2F;更新行为：<br><code>ALTER TABLE 表名 ADD CONSTRAINT 外键名称 FOREIGN KEY (外键字段) REFERENCES 主表名(主表字段名) ON UPDATE 行为 ON DELETE 行为;</code></li>
</ul>
<h2 id="四-多表查询"><a href="#四-多表查询" class="headerlink" title="四.多表查询"></a>四.多表查询</h2><h3 id="4-1-多表关系"><a href="#4-1-多表关系" class="headerlink" title="4.1 多表关系"></a>4.1 多表关系</h3><ul>
<li>一对多（多对一）</li>
<li>多对多</li>
<li>一对一</li>
</ul>
<h4 id="一对多"><a href="#一对多" class="headerlink" title="一对多"></a>一对多</h4><p>案例：部门与员工<br>关系：一个部门对应多个员工，一个员工对应一个部门<br>实现：在多的一方建立外键，指向一的一方的主键</p>
<h4 id="多对多"><a href="#多对多" class="headerlink" title="多对多"></a>多对多</h4><p>案例：学生与课程<br>关系：一个学生可以选多门课程，一门课程也可以供多个学生选修<br>实现：建立第三张中间表，中间表至少包含两个外键，分别关联两方主键</p>
<h4 id="一对一"><a href="#一对一" class="headerlink" title="一对一"></a>一对一</h4><p>案例：用户与用户详情<br>关系：一对一关系，多用于单表拆分，将一张表的基础字段放在一张表中，其他详情字段放在另一张表中，以提升操作效率<br>实现：在任意一方加入外键，关联另外一方的主键，并且设置外键为唯一的（UNIQUE）</p>
<h3 id="4-2-查询"><a href="#4-2-查询" class="headerlink" title="4.2 查询"></a>4.2 查询</h3><p>合并查询（笛卡尔积，会展示所有组合结果）：<br><code>select * from employee, dept;</code></p>
<blockquote>
<p>笛卡尔积：两个集合A集合和B集合的所有组合情况（在多表查询时，需要消除无效的笛卡尔积）</p>
</blockquote>
<p>消除无效笛卡尔积：<br><code>select * from employee, dept where employee.dept = dept.id;</code></p>
<h3 id="4-3-内连接查询"><a href="#4-3-内连接查询" class="headerlink" title="4.3 内连接查询"></a>4.3 内连接查询</h3><p>内连接查询的是两张表交集的部分</p>
<ul>
<li><p>隐式内连接：<br><code>SELECT 字段列表 FROM 表1, 表2 WHERE 条件 ...;</code></p>
</li>
<li><p>显式内连接：<br><code>SELECT 字段列表 FROM 表1 [ INNER ] JOIN 表2 ON 连接条件 ...;</code></p>
</li>
</ul>
<p>显式性能比隐式高</p>
<p>例子：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">-- 查询员工姓名，及关联的部门的名称</span><br><span class="line">-- 隐式</span><br><span class="line">select e.name, d.name from employee as e, dept as d where e.dept = d.id;</span><br><span class="line">-- 显式</span><br><span class="line">select e.name, d.name from employee as e inner join dept as d on e.dept = d.id;</span><br></pre></td></tr></table></figure>

<h3 id="4-4-外连接查询"><a href="#4-4-外连接查询" class="headerlink" title="4.4 外连接查询"></a>4.4 外连接查询</h3><ul>
<li><p>左外连接：<br>查询左表所有数据，以及两张表交集部分数据<br><code>SELECT 字段列表 FROM 表1 LEFT [ OUTER ] JOIN 表2 ON 条件 ...;</code><br>相当于查询表1的所有数据，包含表1和表2交集部分数据</p>
</li>
<li><p>右外连接：<br>查询右表所有数据，以及两张表交集部分数据<br><code>SELECT 字段列表 FROM 表1 RIGHT [ OUTER ] JOIN 表2 ON 条件 ...;</code></p>
</li>
</ul>
<p>例子：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">-- 左</span><br><span class="line">select e.*, d.name from employee as e left outer join dept as d on e.dept = d.id;</span><br><span class="line">select d.name, e.* from dept d left outer join emp e on e.dept = d.id;  -- 这条语句与下面的语句效果一样</span><br><span class="line">-- 右</span><br><span class="line">select d.name, e.* from employee as e right outer join dept as d on e.dept = d.id;</span><br></pre></td></tr></table></figure>

<p>左连接可以查询到没有dept的employee，右连接可以查询到没有employee的dept</p>
<h3 id="4-5-自连接查询"><a href="#4-5-自连接查询" class="headerlink" title="4.5 自连接查询"></a>4.5 自连接查询</h3><p>当前表与自身的连接查询，自连接必须使用表别名</p>
<p>语法：<br><code>SELECT 字段列表 FROM 表A 别名A JOIN 表A 别名B ON 条件 ...;</code></p>
<p>自连接查询，可以是内连接查询，也可以是外连接查询</p>
<p>例子：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">-- 查询员工及其所属领导的名字</span><br><span class="line">select a.name, b.name from employee a, employee b where a.manager = b.id;</span><br><span class="line">-- 没有领导的也查询出来</span><br><span class="line">select a.name, b.name from employee a left join employee b on a.manager = b.id;</span><br></pre></td></tr></table></figure>

<h3 id="4-6-联合查询-union-union-all"><a href="#4-6-联合查询-union-union-all" class="headerlink" title="4.6 联合查询 union, union all"></a>4.6 联合查询 union, union all</h3><p>把多次查询的结果合并，形成一个新的查询集</p>
<p>语法：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">SELECT 字段列表 FROM 表A ...</span><br><span class="line">UNION [ALL]</span><br><span class="line">SELECT 字段列表 FROM 表B ...</span><br></pre></td></tr></table></figure>

<blockquote>
<p>注意事项：</p>
<ul>
<li>UNION ALL 会有重复结果，UNION 不会</li>
<li>联合查询比使用or效率高，不会使索引失效</li>
</ul>
</blockquote>
<h3 id="4-7-子查询"><a href="#4-7-子查询" class="headerlink" title="4.7 子查询"></a>4.7 子查询</h3><p>SQL语句中嵌套SELECT语句，称谓嵌套查询，又称子查询。<br><code>SELECT * FROM t1 WHERE column1 = ( SELECT column1 FROM t2);</code><br><strong>子查询外部的语句可以是 INSERT &#x2F; UPDATE &#x2F; DELETE &#x2F; SELECT 的任何一个</strong></p>
<p>根据子查询结果可以分为：</p>
<ul>
<li>标量子查询（子查询结果为单个值）</li>
<li>列子查询（子查询结果为一列）</li>
<li>行子查询（子查询结果为一行）</li>
<li>表子查询（子查询结果为多行多列）</li>
</ul>
<p>根据子查询位置可分为：</p>
<ul>
<li>WHERE 之后</li>
<li>FROM 之后</li>
<li>SELECT 之后</li>
</ul>
<h4 id="标量子查询"><a href="#标量子查询" class="headerlink" title="标量子查询"></a>标量子查询</h4><p>子查询返回的结果是单个值（数字、字符串、日期等）。<br>常用操作符：- &lt; &gt; &gt; &gt;&#x3D; &lt; &lt;&#x3D;</p>
<p>例子：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">-- 查询销售部所有员工</span><br><span class="line">select id from dept where name = &#x27;销售部&#x27;;</span><br><span class="line">-- 根据销售部部门ID，查询员工信息</span><br><span class="line">select * from employee where dept = 4;</span><br><span class="line">-- 合并（子查询）</span><br><span class="line">select * from employee where dept = (select id from dept where name = &#x27;销售部&#x27;);</span><br><span class="line"></span><br><span class="line">-- 查询xxx入职之后的员工信息</span><br><span class="line">select * from employee where entrydate &gt; (select entrydate from employee where name = &#x27;xxx&#x27;);</span><br></pre></td></tr></table></figure>

<h4 id="列子查询"><a href="#列子查询" class="headerlink" title="列子查询"></a>列子查询</h4><p>返回的结果是一列（可以是多行）。</p>
<p>常用操作符：</p>
<table>
<thead>
<tr>
<th align="center">操作符</th>
<th align="center">描述</th>
</tr>
</thead>
<tbody><tr>
<td align="center">IN</td>
<td align="center">在指定的集合范围内，多选一</td>
</tr>
<tr>
<td align="center">NOT IN</td>
<td align="center">不在指定的集合范围内</td>
</tr>
<tr>
<td align="center">ANY</td>
<td align="center">子查询返回列表中，有任意一个满足即可</td>
</tr>
<tr>
<td align="center">SOME</td>
<td align="center">与ANY等同，使用SOME的地方都可以使用ANY</td>
</tr>
<tr>
<td align="center">ALL</td>
<td align="center">子查询返回列表的所有值都必须满足</td>
</tr>
</tbody></table>
<p>例子：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">-- 查询销售部和市场部的所有员工信息</span><br><span class="line">select * from employee where dept in (select id from dept where name = &#x27;销售部&#x27; or name = &#x27;市场部&#x27;);</span><br><span class="line">-- 查询比财务部所有人工资都高的员工信息</span><br><span class="line">select * from employee where salary &gt; all(select salary from employee where dept = (select id from dept where name = &#x27;财务部&#x27;));</span><br><span class="line">-- 查询比研发部任意一人工资高的员工信息</span><br><span class="line">select * from employee where salary &gt; any (select salary from employee where dept = (select id from dept where name = &#x27;研发部&#x27;));</span><br></pre></td></tr></table></figure>

<h4 id="行子查询"><a href="#行子查询" class="headerlink" title="行子查询"></a>行子查询</h4><p>返回的结果是一行（可以是多列）。<br>常用操作符：&#x3D;, &lt;, &gt;, IN, NOT IN</p>
<p>例子：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">-- 查询与xxx的薪资及直属领导相同的员工信息</span><br><span class="line">select * from employee where (salary, manager) = (12500, 1);</span><br><span class="line">select * from employee where (salary, manager) = (select salary, manager from employee where name = &#x27;xxx&#x27;);</span><br></pre></td></tr></table></figure>

<h4 id="表子查询"><a href="#表子查询" class="headerlink" title="表子查询"></a>表子查询</h4><p>返回的结果是多行多列<br>常用操作符：IN</p>
<p>例子：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">-- 查询与xxx1，xxx2的职位和薪资相同的员工</span><br><span class="line">select * from employee where (job, salary) in (select job, salary from employee where name = &#x27;xxx1&#x27; or name = &#x27;xxx2&#x27;);</span><br><span class="line">-- 查询入职日期是2006-01-01之后的员工，及其部门信息</span><br><span class="line">select e.*, d.* from (select * from employee where entrydate &gt; &#x27;2006-01-01&#x27;) as e left join dept as d on e.dept = d.id;</span><br></pre></td></tr></table></figure>

<h2 id="五-事务"><a href="#五-事务" class="headerlink" title="五.事务"></a>五.事务</h2><p>事务是一组操作的集合，事务会把所有操作作为一个整体一起向系统提交或撤销操作请求，即这些操作要么同时成功，要么同时失败。</p>
<p>基本操作：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br></pre></td><td class="code"><pre><span class="line">-- 1. 查询张三账户余额</span><br><span class="line">select * from account where name = &#x27;张三&#x27;;</span><br><span class="line">-- 2. 将张三账户余额-1000</span><br><span class="line">update account set money = money - 1000 where name = &#x27;张三&#x27;;</span><br><span class="line">-- 此语句出错后张三钱减少但是李四钱没有增加</span><br><span class="line">模拟sql语句错误</span><br><span class="line">-- 3. 将李四账户余额+1000</span><br><span class="line">update account set money = money + 1000 where name = &#x27;李四&#x27;;</span><br><span class="line"></span><br><span class="line">-- 查看事务提交方式</span><br><span class="line">SELECT @@AUTOCOMMIT;</span><br><span class="line">-- 设置事务提交方式，1为自动提交，0为手动提交，该设置只对当前会话有效</span><br><span class="line">SET @@AUTOCOMMIT = 0;</span><br><span class="line">-- 提交事务</span><br><span class="line">COMMIT;</span><br><span class="line">-- 回滚事务</span><br><span class="line">ROLLBACK;</span><br><span class="line"></span><br><span class="line">-- 设置手动提交后上面代码改为：</span><br><span class="line">select * from account where name = &#x27;张三&#x27;;</span><br><span class="line">update account set money = money - 1000 where name = &#x27;张三&#x27;;</span><br><span class="line">update account set money = money + 1000 where name = &#x27;李四&#x27;;</span><br><span class="line">commit;</span><br></pre></td></tr></table></figure>

<p>操作方式二：</p>
<p>开启事务：<br><code>START TRANSACTION 或 BEGIN TRANSACTION;</code><br>提交事务：<br><code>COMMIT;</code><br>回滚事务：<br><code>ROLLBACK;</code></p>
<p>操作实例：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">start transaction;</span><br><span class="line">select * from account where name = &#x27;张三&#x27;;</span><br><span class="line">update account set money = money - 1000 where name = &#x27;张三&#x27;;</span><br><span class="line">update account set money = money + 1000 where name = &#x27;李四&#x27;;</span><br><span class="line">commit;</span><br></pre></td></tr></table></figure>

<h3 id="5-1-四大特性ACID"><a href="#5-1-四大特性ACID" class="headerlink" title="5.1 四大特性ACID"></a>5.1 四大特性ACID</h3><ul>
<li>原子性(Atomicity)：事务是不可分割的最小操作但愿，要么全部成功，要么全部失败</li>
<li>一致性(Consistency)：事务完成时，必须使所有数据都保持一致状态</li>
<li>隔离性(Isolation)：数据库系统提供的隔离机制，保证事务在不受外部并发操作影响的独立环境下运行</li>
<li>持久性(Durability)：事务一旦提交或回滚，它对数据库中的数据的改变就是永久的</li>
</ul>
<h3 id="5-2-并发事务"><a href="#5-2-并发事务" class="headerlink" title="5.2 并发事务"></a>5.2 并发事务</h3><table>
<thead>
<tr>
<th align="center">问题</th>
<th align="center">描述</th>
</tr>
</thead>
<tbody><tr>
<td align="center">脏读</td>
<td align="center">一个事务读到另一个事务还没提交的数据</td>
</tr>
<tr>
<td align="center">不可重复读</td>
<td align="center">一个事务先后读取同一条记录，但两次读取的数据不同</td>
</tr>
<tr>
<td align="center">幻读</td>
<td align="center">一个事务按照条件查询数据时，没有对应的数据行，但是再插入数据时，又发现这行数据已经存在</td>
</tr>
</tbody></table>
<blockquote>
<p>这三个问题的详细演示：<a target="_blank" rel="noopener" href="https://www.bilibili.com/video/BV1Kr4y1i7ru?p=55cd">https://www.bilibili.com/video/BV1Kr4y1i7ru?p=55cd</a> </p>
</blockquote>
<p>并发事务隔离级别：</p>
<table>
<thead>
<tr>
<th align="center">隔离级别</th>
<th align="center">脏读</th>
<th align="center">不可重复读</th>
<th align="center">幻读</th>
</tr>
</thead>
<tbody><tr>
<td align="center">Read uncommitted</td>
<td align="center">√</td>
<td align="center">√</td>
<td align="center">√</td>
</tr>
<tr>
<td align="center">Read committed</td>
<td align="center">×</td>
<td align="center">√</td>
<td align="center">√</td>
</tr>
<tr>
<td align="center">Repeatable Read(默认)</td>
<td align="center">×</td>
<td align="center">×</td>
<td align="center">√</td>
</tr>
<tr>
<td align="center">Serializable</td>
<td align="center">×</td>
<td align="center">×</td>
<td align="center">×</td>
</tr>
</tbody></table>
<ul>
<li>√表示在当前隔离级别下该问题会出现</li>
<li>Serializable 性能最低；Read uncommitted 性能最高，数据安全性最差</li>
</ul>
<p>查看事务隔离级别：<br><code>SELECT @@TRANSACTION_ISOLATION;</code><br>设置事务隔离级别：<br><code>SET [ SESSION | GLOBAL ] TRANSACTION ISOLATION LEVEL &#123;READ UNCOMMITTED | READ COMMITTED | REPEATABLE READ | SERIALIZABLE &#125;;</code><br>SESSION 是会话级别，表示只针对当前会话有效，GLOBAL 表示对所有会话有效</p>
<h1 id="进阶篇"><a href="#进阶篇" class="headerlink" title="进阶篇"></a>进阶篇</h1><h2 id="一-存储引擎"><a href="#一-存储引擎" class="headerlink" title="一.存储引擎"></a>一.存储引擎</h2><p>MySQL体系结构：</p>
<p><img src="https://dustwind-picture-upload.oss-cn-chengdu.aliyuncs.com/img/MySQL%E4%BD%93%E7%B3%BB%E7%BB%93%E6%9E%84.png" alt="结构图" title="结构图"><br><img src="https://dustwind-picture-upload.oss-cn-chengdu.aliyuncs.com/img/MySQL%E5%B1%82%E7%BA%A7%E6%8F%8F%E8%BF%B0.png" alt="层级描述" title="层级描述"></p>
<p>存储引擎就是存储数据、建立索引、更新&#x2F;查询数据等技术的实现方式。存储引擎是基于表而不是基于库的，所以存储引擎也可以被称为表引擎。<br>默认存储引擎是InnoDB。</p>
<p>相关操作：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">-- 查询建表语句</span><br><span class="line">show create table account;</span><br><span class="line">-- 建表时指定存储引擎</span><br><span class="line">CREATE TABLE 表名(</span><br><span class="line">	...</span><br><span class="line">) ENGINE=INNODB;</span><br><span class="line">-- 查看当前数据库支持的存储引擎</span><br><span class="line">show engines;</span><br></pre></td></tr></table></figure>

<h3 id="1-1-InnoDB"><a href="#1-1-InnoDB" class="headerlink" title="1.1 InnoDB"></a>1.1 InnoDB</h3><p>InnoDB 是一种兼顾高可靠性和高性能的通用存储引擎，在 MySQL 5.5 之后，InnoDB 是默认的 MySQL 引擎。</p>
<p>特点：</p>
<ul>
<li>DML 操作遵循 ACID 模型，支持<strong>事务</strong></li>
<li><strong>行级锁</strong>，提高并发访问性能</li>
<li>支持<strong>外键</strong>约束，保证数据的完整性和正确性</li>
</ul>
<p>文件：</p>
<ul>
<li>xxx.ibd: xxx代表表名，InnoDB 引擎的每张表都会对应这样一个表空间文件，存储该表的表结构（frm、sdi）、数据和索引。</li>
</ul>
<p>参数：innodb_file_per_table，决定多张表共享一个表空间还是每张表对应一个表空间</p>
<p>知识点：</p>
<p>查看 Mysql 变量：<br><code>show variables like &#39;innodb_file_per_table&#39;;</code></p>
<p>从idb文件提取表结构数据：<br>（在cmd运行）<br><code>ibd2sdi xxx.ibd</code></p>
<p>InnoDB 逻辑存储结构：<br><img src="https://dustwind-picture-upload.oss-cn-chengdu.aliyuncs.com/img/InnoDB%E9%80%BB%E8%BE%91%E5%AD%98%E5%82%A8%E7%BB%93%E6%9E%84.png" alt="InnoDB逻辑存储结构" title="InnoDB逻辑存储结构"></p>
<h3 id="1-2-MyISAM"><a href="#1-2-MyISAM" class="headerlink" title="1.2 MyISAM"></a>1.2 MyISAM</h3><p>MyISAM 是 MySQL 早期的默认存储引擎。</p>
<p>特点：</p>
<ul>
<li>不支持事务，不支持外键</li>
<li>支持表锁，不支持行锁</li>
<li>访问速度快</li>
</ul>
<p>文件：</p>
<ul>
<li>xxx.sdi: 存储表结构信息</li>
<li>xxx.MYD: 存储数据</li>
<li>xxx.MYI: 存储索引</li>
</ul>
<h3 id="1-3-Memory"><a href="#1-3-Memory" class="headerlink" title="1.3 Memory"></a>1.3 Memory</h3><p>Memory 引擎的表数据是存储在内存中的，受硬件问题、断电问题的影响，只能将这些表作为临时表或缓存使用。</p>
<p>特点：</p>
<ul>
<li>存放在内存中，速度快</li>
<li>hash索引（默认）</li>
</ul>
<p>文件：</p>
<ul>
<li>xxx.sdi: 存储表结构信息</li>
</ul>
<h3 id="1-4-存储引擎特点"><a href="#1-4-存储引擎特点" class="headerlink" title="1.4 存储引擎特点"></a>1.4 存储引擎特点</h3><table>
<thead>
<tr>
<th align="center">特点</th>
<th align="center">InnoDB</th>
<th align="center">MyISAM</th>
<th align="center">Memory</th>
</tr>
</thead>
<tbody><tr>
<td align="center">存储限制</td>
<td align="center">64TB</td>
<td align="center">有</td>
<td align="center">有</td>
</tr>
<tr>
<td align="center">事务安全</td>
<td align="center">支持</td>
<td align="center">-</td>
<td align="center">-</td>
</tr>
<tr>
<td align="center">锁机制</td>
<td align="center">行锁</td>
<td align="center">表锁</td>
<td align="center">表锁</td>
</tr>
<tr>
<td align="center">B+tree索引</td>
<td align="center">支持</td>
<td align="center">支持</td>
<td align="center">支持</td>
</tr>
<tr>
<td align="center">Hash索引</td>
<td align="center">-</td>
<td align="center">-</td>
<td align="center">支持</td>
</tr>
<tr>
<td align="center">全文索引</td>
<td align="center">支持（5.6版本之后）</td>
<td align="center">支持</td>
<td align="center">-</td>
</tr>
<tr>
<td align="center">空间使用</td>
<td align="center">高</td>
<td align="center">低</td>
<td align="center">N&#x2F;A</td>
</tr>
<tr>
<td align="center">内存使用</td>
<td align="center">高</td>
<td align="center">低</td>
<td align="center">中等</td>
</tr>
<tr>
<td align="center">批量插入速度</td>
<td align="center">低</td>
<td align="center">高</td>
<td align="center">高</td>
</tr>
<tr>
<td align="center">支持外键</td>
<td align="center">支持</td>
<td align="center">-</td>
<td align="center">-</td>
</tr>
</tbody></table>
<h3 id="1-5-存储引擎的选择"><a href="#1-5-存储引擎的选择" class="headerlink" title="1.5 存储引擎的选择"></a>1.5 存储引擎的选择</h3><p>在选择存储引擎时，应该根据应用系统的特点选择合适的存储引擎。对于复杂的应用系统，还可以根据实际情况选择多种存储引擎进行组合。</p>
<ul>
<li>InnoDB: 如果应用对事物的完整性有比较高的要求，在并发条件下要求数据的一致性，数据操作除了插入和查询之外，还包含很多的更新、删除操作，则 InnoDB 是比较合适的选择</li>
<li>MyISAM: 如果应用是以读操作和插入操作为主，只有很少的更新和删除操作，并且对事务的完整性、并发性要求不高，那这个存储引擎是非常合适的。</li>
<li>Memory: 将所有数据保存在内存中，访问速度快，通常用于临时表及缓存。Memory 的缺陷是对表的大小有限制，太大的表无法缓存在内存中，而且无法保障数据的安全性</li>
</ul>
<p>电商中的足迹和评论适合使用 MyISAM 引擎，缓存适合使用 Memory 引擎。</p>
<h2 id="二-性能分析"><a href="#二-性能分析" class="headerlink" title="二.性能分析"></a>二.性能分析</h2><h3 id="2-1-查看执行频次"><a href="#2-1-查看执行频次" class="headerlink" title="2.1 查看执行频次"></a>2.1 查看执行频次</h3><p>查看当前数据库的 INSERT, UPDATE, DELETE, SELECT 访问频次：<br><code>SHOW GLOBAL STATUS LIKE &#39;Com_______&#39;;</code> 或者 <code>SHOW SESSION STATUS LIKE &#39;Com_______&#39;;</code><br>例：<code>show global status like &#39;Com_______&#39;</code></p>
<h3 id="2-2-慢查询日志"><a href="#2-2-慢查询日志" class="headerlink" title="2.2 慢查询日志"></a>2.2 慢查询日志</h3><p>慢查询日志记录了所有执行时间超过指定参数（long_query_time，单位：秒，默认10秒）的所有SQL语句的日志。<br>MySQL的慢查询日志默认没有开启，需要在MySQL的配置文件（&#x2F;etc&#x2F;my.cnf）中配置如下信息：<br>    # 开启慢查询日志开关<br>    slow_query_log&#x3D;1<br>    # 设置慢查询日志的时间为2秒，SQL语句执行时间超过2秒，就会视为慢查询，记录慢查询日志<br>    long_query_time&#x3D;2<br>更改后记得重启MySQL服务，日志文件位置：&#x2F;var&#x2F;lib&#x2F;mysql&#x2F;localhost-slow.log</p>
<p>查看慢查询日志开关状态：<br><code>show variables like &#39;slow_query_log&#39;;</code></p>
<h3 id="2-3-profile"><a href="#2-3-profile" class="headerlink" title="2.3 profile"></a>2.3 profile</h3><p>show profile 能在做SQL优化时帮我们了解时间都耗费在哪里。通过 have_profiling 参数，能看到当前 MySQL 是否支持 profile 操作：<br><code>SELECT @@have_profiling;</code><br>profiling 默认关闭，可以通过set语句在session&#x2F;global级别开启 profiling：<br><code>SET profiling = 1;</code><br>查看所有语句的耗时：<br><code>show profiles;</code><br>查看指定query_id的SQL语句各个阶段的耗时：<br><code>show profile for query query_id;</code><br>查看指定query_id的SQL语句CPU的使用情况<br><code>show profile cpu for query query_id;</code></p>
<h3 id="2-4-explain"><a href="#2-4-explain" class="headerlink" title="2.4 explain"></a>2.4 explain</h3><p>EXPLAIN 或者 DESC 命令获取 MySQL 如何执行 SELECT 语句的信息，包括在 SELECT 语句执行过程中表如何连接和连接的顺序。<br>语法：<br>    # 直接在select语句之前加上关键字 explain &#x2F; desc<br>​	EXPLAIN SELECT 字段列表 FROM 表名 HWERE 条件;</p>
<p>EXPLAIN 各字段含义：</p>
<ul>
<li>id：select 查询的序列号，表示查询中执行 select 子句或者操作表的顺序（id相同，执行顺序从上到下；id不同，值越大越先执行）</li>
<li>select_type：表示 SELECT 的类型，常见取值有 SIMPLE（简单表，即不适用表连接或者子查询）、PRIMARY（主查询，即外层的查询）、UNION（UNION中的第二个或者后面的查询语句）、SUBQUERY（SELECT&#x2F;WHERE之后包含了子查询）等</li>
<li>type：表示连接类型，性能由好到差的连接类型为 NULL、system、const、eq_ref、ref、range、index、all</li>
<li>possible_key：可能应用在这张表上的索引，一个或多个</li>
<li>Key：实际使用的索引，如果为 NULL，则没有使用索引</li>
<li>Key_len：表示索引中使用的字节数，该值为索引字段最大可能长度，并非实际使用长度，在不损失精确性的前提下，长度越短越好</li>
<li>rows：MySQL认为必须要执行的行数，在InnoDB引擎的表中，是一个估计值，可能并不总是准确的</li>
<li>filtered：表示返回结果的行数占需读取行数的百分比，filtered的值越大越好</li>
</ul>
<h2 id="三-索引"><a href="#三-索引" class="headerlink" title="三.索引"></a>三.索引</h2><p>索引是帮助 MySQL <strong>高效获取数据</strong>的<strong>数据结构（有序）</strong>。在数据之外，数据库系统还维护着满足特定查找算法的数据结构，这些数据结构以某种方式引用（指向）数据，这样就可以在这些数据结构上实现高级查询算法，这种数据结构就是索引。</p>
<p>优缺点：</p>
<p>优点：</p>
<ul>
<li>提高数据检索效率，降低数据库的IO成本</li>
<li>通过索引列对数据进行排序，降低数据排序的成本，降低CPU的消耗</li>
</ul>
<p>缺点：</p>
<ul>
<li>索引列也是要占用空间的</li>
<li>索引大大提高了查询效率，但降低了更新的速度，比如 INSERT、UPDATE、DELETE</li>
</ul>
<h3 id="3-1-索引结构"><a href="#3-1-索引结构" class="headerlink" title="3.1 索引结构"></a>3.1 索引结构</h3><table>
<thead>
<tr>
<th align="center">索引结构</th>
<th align="center">描述</th>
</tr>
</thead>
<tbody><tr>
<td align="center">B+Tree</td>
<td align="center">最常见的索引类型，大部分引擎都支持B+树索引</td>
</tr>
<tr>
<td align="center">Hash</td>
<td align="center">底层数据结构是用哈希表实现，只有精确匹配索引列的查询才有效，不支持范围查询</td>
</tr>
<tr>
<td align="center">R-Tree(空间索引)</td>
<td align="center">空间索引是 MyISAM 引擎的一个特殊索引类型，主要用于地理空间数据类型，通常使用较少</td>
</tr>
<tr>
<td align="center">Full-Text(全文索引)</td>
<td align="center">是一种通过建立倒排索引，快速匹配文档的方式，类似于 Lucene, Solr, ES</td>
</tr>
</tbody></table>
<table>
<thead>
<tr>
<th align="center">索引</th>
<th align="center">InnoDB</th>
<th align="center">MyISAM</th>
<th align="center">Memory</th>
</tr>
</thead>
<tbody><tr>
<td align="center">B+Tree索引</td>
<td align="center">支持</td>
<td align="center">支持</td>
<td align="center">支持</td>
</tr>
<tr>
<td align="center">Hash索引</td>
<td align="center">不支持</td>
<td align="center">不支持</td>
<td align="center">支持</td>
</tr>
<tr>
<td align="center">R-Tree索引</td>
<td align="center">不支持</td>
<td align="center">支持</td>
<td align="center">不支持</td>
</tr>
<tr>
<td align="center">Full-text</td>
<td align="center">5.6版本后支持</td>
<td align="center">支持</td>
<td align="center">不支持</td>
</tr>
</tbody></table>
<h4 id="3-1-1-B-Tree"><a href="#3-1-1-B-Tree" class="headerlink" title="3.1.1 B-Tree"></a>3.1.1 B-Tree</h4><p><img src="https://dustwind-picture-upload.oss-cn-chengdu.aliyuncs.com/img/%E4%BA%8C%E5%8F%89%E6%A0%91.png" alt="二叉树" title="二叉树"></p>
<p>二叉树的缺点可以用红黑树来解决：<br><img src="https://dustwind-picture-upload.oss-cn-chengdu.aliyuncs.com/img/%E7%BA%A2%E9%BB%91%E6%A0%91.png" alt="红黑树" title="红黑树"><br>红黑树也存在大数据量情况下，层级较深，检索速度慢的问题。</p>
<p>为了解决上述问题，可以使用 B-Tree 结构。<br>B-Tree (多路平衡查找树) 以一棵最大度数（max-degree，指一个节点的子节点个数）为5（5阶）的 b-tree 为例（每个节点最多存储4个key，5个指针）</p>
<p><img src="https://dustwind-picture-upload.oss-cn-chengdu.aliyuncs.com/img/B-Tree%E7%BB%93%E6%9E%84.png" alt="B-Tree结构" title="B-Tree结构"></p>
<blockquote>
<p>B-Tree 的数据插入过程动画参照：<a target="_blank" rel="noopener" href="https://www.bilibili.com/video/BV1Kr4y1i7ru?p=68">https://www.bilibili.com/video/BV1Kr4y1i7ru?p=68</a><br>演示地址：<a target="_blank" rel="noopener" href="https://www.cs.usfca.edu/~galles/visualization/BTree.html">https://www.cs.usfca.edu/~galles/visualization/BTree.html</a></p>
</blockquote>
<h4 id="3-1-2-B-Tree"><a href="#3-1-2-B-Tree" class="headerlink" title="3.1.2 B+Tree"></a>3.1.2 B+Tree</h4><p>结构图：</p>
<p><img src="https://dustwind-picture-upload.oss-cn-chengdu.aliyuncs.com/img/B%E5%8A%A0Tree%E7%BB%93%E6%9E%84%E5%9B%BE.png" alt="B+Tree结构图" title="B+Tree结构图"></p>
<blockquote>
<p>演示地址：<a target="_blank" rel="noopener" href="https://www.cs.usfca.edu/~galles/visualization/BPlusTree.html">https://www.cs.usfca.edu/~galles/visualization/BPlusTree.html</a></p>
</blockquote>
<p>与 B-Tree 的区别：</p>
<ul>
<li>所有的数据都会出现在叶子节点</li>
<li>叶子节点形成一个单向链表</li>
</ul>
<p>MySQL 索引数据结构对经典的 B+Tree 进行了优化。在原 B+Tree 的基础上，增加一个指向相邻叶子节点的链表指针，就形成了带有顺序指针的 B+Tree，提高区间访问的性能。</p>
<p><img src="https://dustwind-picture-upload.oss-cn-chengdu.aliyuncs.com/img/MySQL%20B%E5%8A%A0Tree%20%E7%BB%93%E6%9E%84%E5%9B%BE.png" alt="MySQL B+Tree 结构图" title="MySQL B+Tree 结构图"></p>
<h4 id="3-1-3-Hash"><a href="#3-1-3-Hash" class="headerlink" title="3.1.3 Hash"></a>3.1.3 Hash</h4><p>哈希索引就是采用一定的hash算法，将键值换算成新的hash值，映射到对应的槽位上，然后存储在hash表中。<br>如果两个（或多个）键值，映射到一个相同的槽位上，他们就产生了hash冲突（也称为hash碰撞），可以通过链表来解决。</p>
<p><img src="https://dustwind-picture-upload.oss-cn-chengdu.aliyuncs.com/img/Hash%E7%B4%A2%E5%BC%95%E5%8E%9F%E7%90%86%E5%9B%BE.png" alt="Hash索引原理图" title="Hash索引原理图"></p>
<p>特点：</p>
<ul>
<li>Hash索引只能用于对等比较（&#x3D;、in），不支持范围查询（betwwn、&gt;、&lt;、…）</li>
<li>无法利用索引完成排序操作</li>
<li>查询效率高，通常只需要一次检索就可以了，效率通常要高于 B+Tree 索引</li>
</ul>
<p>存储引擎支持：</p>
<ul>
<li>Memory</li>
<li>InnoDB: 具有自适应hash功能，hash索引是存储引擎根据 B+Tree 索引在指定条件下自动构建的</li>
</ul>
<h4 id="面试题"><a href="#面试题" class="headerlink" title="面试题"></a>面试题</h4><ol>
<li>为什么 InnoDB 存储引擎选择使用 B+Tree 索引结构？</li>
</ol>
<ul>
<li>相对于二叉树，层级更少，搜索效率高</li>
<li>对于 B-Tree，无论是叶子节点还是非叶子节点，都会保存数据，这样导致一页中存储的键值减少，指针也跟着减少，要同样保存大量数据，只能增加树的高度，导致性能降低</li>
<li>相对于 Hash 索引，B+Tree 支持范围匹配及排序操作</li>
</ul>
<h3 id="3-2-索引分类"><a href="#3-2-索引分类" class="headerlink" title="3.2 索引分类"></a>3.2 索引分类</h3><table>
<thead>
<tr>
<th align="center">分类</th>
<th align="center">含义</th>
<th align="center">特点</th>
<th align="center">关键字</th>
</tr>
</thead>
<tbody><tr>
<td align="center">主键索引</td>
<td align="center">针对于表中主键创建的索引</td>
<td align="center">默认自动创建，只能有一个</td>
<td align="center">PRIMARY</td>
</tr>
<tr>
<td align="center">唯一索引</td>
<td align="center">避免同一个表中某数据列中的值重复</td>
<td align="center">可以有多个</td>
<td align="center">UNIQUE</td>
</tr>
<tr>
<td align="center">常规索引</td>
<td align="center">快速定位特定数据</td>
<td align="center">可以有多个</td>
<td align="center"></td>
</tr>
<tr>
<td align="center">全文索引</td>
<td align="center">全文索引查找的是文本中的关键词，而不是比较索引中的值</td>
<td align="center">可以有多个</td>
<td align="center">FULLTEXT</td>
</tr>
</tbody></table>
<p>在 InnoDB 存储引擎中，根据索引的存储形式，又可以分为以下两种：</p>
<table>
<thead>
<tr>
<th align="center">分类</th>
<th align="center">含义</th>
<th align="center">特点</th>
</tr>
</thead>
<tbody><tr>
<td align="center">聚集索引(Clustered Index)</td>
<td align="center">将数据存储与索引放一块，索引结构的叶子节点保存了行数据</td>
<td align="center">必须有，而且只有一个</td>
</tr>
<tr>
<td align="center">二级索引(Secondary Index)</td>
<td align="center">将数据与索引分开存储，索引结构的叶子节点关联的是对应的主键</td>
<td align="center">可以存在多个</td>
</tr>
</tbody></table>
<p>演示图：</p>
<p><img src="https://dustwind-picture-upload.oss-cn-chengdu.aliyuncs.com/img/%E5%A4%A7%E8%87%B4%E5%8E%9F%E7%90%86.png" alt="大致原理" title="大致原理"><br><img src="https://dustwind-picture-upload.oss-cn-chengdu.aliyuncs.com/img/%E6%BC%94%E7%A4%BA%E5%9B%BE.png" alt="演示图" title="演示图"></p>
<p>聚集索引选取规则：</p>
<ul>
<li>如果存在主键，主键索引就是聚集索引</li>
<li>如果不存在主键，将使用第一个唯一(UNIQUE)索引作为聚集索引</li>
<li>如果表没有主键或没有合适的唯一索引，则 InnoDB 会自动生成一个 rowid 作为隐藏的聚集索引</li>
</ul>
<h4 id="思考题"><a href="#思考题" class="headerlink" title="思考题"></a>思考题</h4><p>1. 以下 SQL 语句，哪个执行效率高？为什么？</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">select * from user where id = 10;</span><br><span class="line">select * from user where name = &#x27;Arm&#x27;;</span><br><span class="line">-- 备注：id为主键，name字段创建的有索引</span><br></pre></td></tr></table></figure>

<p>答：第一条语句，因为第二条需要回表查询，相当于两个步骤。</p>
<p>2. InnoDB 主键索引的 B+Tree 高度为多少？</p>
<p>答：假设一行数据大小为1k，一页中可以存储16行这样的数据。InnoDB 的指针占用6个字节的空间，主键假设为bigint，占用字节数为8.<br>可得公式：<code>n * 8 + (n + 1) * 6 = 16 * 1024</code>，其中 8 表示 bigint 占用的字节数，n 表示当前节点存储的key的数量，(n + 1) 表示指针数量（比key多一个）。算出n约为1170。</p>
<p>如果树的高度为2，那么他能存储的数据量大概为：<code>1171 * 16 = 18736</code>；<br>如果树的高度为3，那么他能存储的数据量大概为：<code>1171 * 1171 * 16 = 21939856</code>。</p>
<p>另外，如果有成千上万的数据，那么就要考虑分表，涉及运维篇知识。</p>
<h3 id="3-3-语法"><a href="#3-3-语法" class="headerlink" title="3.3 语法"></a>3.3 语法</h3><p>创建索引：<br><code>CREATE [ UNIQUE | FULLTEXT ] INDEX index_name ON table_name (index_col_name, ...);</code><br>如果不加 CREATE 后面不加索引类型参数，则创建的是常规索引</p>
<p>查看索引：<br><code>SHOW INDEX FROM table_name;</code></p>
<p>删除索引：<br><code>DROP INDEX index_name ON table_name;</code></p>
<p>案例：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line">-- name字段为姓名字段，该字段的值可能会重复，为该字段创建索引</span><br><span class="line">create index idx_user_name on tb_user(name);</span><br><span class="line">-- phone手机号字段的值非空，且唯一，为该字段创建唯一索引</span><br><span class="line">create unique index idx_user_phone on tb_user (phone);</span><br><span class="line">-- 为profession, age, status创建联合索引</span><br><span class="line">create index idx_user_pro_age_stat on tb_user(profession, age, status);</span><br><span class="line">-- 为email建立合适的索引来提升查询效率</span><br><span class="line">create index idx_user_email on tb_user(email);</span><br><span class="line"></span><br><span class="line">-- 删除索引</span><br><span class="line">drop index idx_user_email on tb_user;</span><br></pre></td></tr></table></figure>

<h3 id="3-4-使用规则"><a href="#3-4-使用规则" class="headerlink" title="3.4 使用规则"></a>3.4 使用规则</h3><h4 id="3-4-1-最左前缀法则"><a href="#3-4-1-最左前缀法则" class="headerlink" title="3.4.1 最左前缀法则"></a>3.4.1 最左前缀法则</h4><p>如果索引关联了多列（联合索引），要遵守最左前缀法则，最左前缀法则指的是查询从索引的最左列开始，并且不跳过索引中的列。<br>如果跳跃某一列，索引将部分失效（后面的字段索引失效）。</p>
<p>联合索引中，出现范围查询（&lt;, &gt;），范围查询右侧的列索引失效。可以用&gt;&#x3D;或者&lt;&#x3D;来规避索引失效问题。</p>
<h4 id="3-4-2-索引失效情况"><a href="#3-4-2-索引失效情况" class="headerlink" title="3.4.2 索引失效情况"></a>3.4.2 索引失效情况</h4><ol>
<li>在索引列上进行运算操作，索引将失效。如：<code>explain select * from tb_user where substring(phone, 10, 2) = &#39;15&#39;;</code></li>
<li>字符串类型字段使用时，不加引号，索引将失效。如：<code>explain select * from tb_user where phone = 17799990015;</code>，此处phone的值没有加引号</li>
<li>模糊查询中，如果仅仅是尾部模糊匹配，索引不会是失效；如果是头部模糊匹配，索引失效。如：<code>explain select * from tb_user where profession like &#39;%工程&#39;;</code>，前后都有 % 也会失效。</li>
<li>用 or 分割开的条件，如果 or 其中一个条件的列没有索引，那么涉及的索引都不会被用到。</li>
<li>如果 MySQL 评估使用索引比全表更慢，则不使用索引。</li>
</ol>
<h4 id="3-4-3-SQL-提示"><a href="#3-4-3-SQL-提示" class="headerlink" title="3.4.3 SQL 提示"></a>3.4.3 SQL 提示</h4><p>是优化数据库的一个重要手段，简单来说，就是在SQL语句中加入一些人为的提示来达到优化操作的目的。</p>
<p>例如，使用索引：<br><code>explain select * from tb_user use index(idx_user_pro) where profession=&quot;软件工程&quot;;</code><br>不使用哪个索引：<br><code>explain select * from tb_user ignore index(idx_user_pro) where profession=&quot;软件工程&quot;;</code><br>必须使用哪个索引：<br><code>explain select * from tb_user force index(idx_user_pro) where profession=&quot;软件工程&quot;;</code></p>
<p>use 是建议，实际使用哪个索引 MySQL 还会自己权衡运行速度去更改，force就是无论如何都强制使用该索引。</p>
<h4 id="3-4-4-覆盖索引-回表查询"><a href="#3-4-4-覆盖索引-回表查询" class="headerlink" title="3.4.4 覆盖索引&amp;回表查询"></a>3.4.4 覆盖索引&amp;回表查询</h4><p>尽量使用覆盖索引（查询使用了索引，并且需要返回的列，在该索引中已经全部能找到），减少 select *。</p>
<p>explain 中 extra 字段含义：<br><code>using index condition</code>：查找使用了索引，但是需要回表查询数据<br><code>using where; using index;</code>：查找使用了索引，但是需要的数据都在索引列中能找到，所以不需要回表查询</p>
<p>如果在聚集索引中直接能找到对应的行，则直接返回行数据，只需要一次查询，哪怕是select *；如果在辅助索引中找聚集索引，如<code>select id, name from xxx where name=&#39;xxx&#39;;</code>，也只需要通过辅助索引(name)查找到对应的id，返回name和name索引对应的id即可，只需要一次查询；如果是通过辅助索引查找其他字段，则需要回表查询，如<code>select id, name, gender from xxx where name=&#39;xxx&#39;;</code></p>
<p>所以尽量不要用<code>select *</code>，容易出现回表查询，降低效率，除非有联合索引包含了所有字段</p>
<p>面试题：一张表，有四个字段（id, username, password, status），由于数据量大，需要对以下SQL语句进行优化，该如何进行才是最优方案：<br><code>select id, username, password from tb_user where username=&#39;itcast&#39;;</code></p>
<p>解：给username和password字段建立联合索引，则不需要回表查询，直接覆盖索引</p>
<h4 id="3-4-5-前缀索引"><a href="#3-4-5-前缀索引" class="headerlink" title="3.4.5 前缀索引"></a>3.4.5 前缀索引</h4><p>当字段类型为字符串（varchar, text等）时，有时候需要索引很长的字符串，这会让索引变得很大，查询时，浪费大量的磁盘IO，影响查询效率，此时可以只降字符串的一部分前缀，建立索引，这样可以大大节约索引空间，从而提高索引效率。</p>
<p>语法：<code>create index idx_xxxx on table_name(columnn(n));</code><br>前缀长度：可以根据索引的选择性来决定，而选择性是指不重复的索引值（基数）和数据表的记录总数的比值，索引选择性越高则查询效率越高，唯一索引的选择性是1，这是最好的索引选择性，性能也是最好的。<br>求选择性公式：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">select count(distinct email) / count(*) from tb_user;</span><br><span class="line">select count(distinct substring(email, 1, 5)) / count(*) from tb_user;</span><br></pre></td></tr></table></figure>

<p>show index 里面的sub_part可以看到接取的长度</p>
<h4 id="3-4-6-单列索引-联合索引"><a href="#3-4-6-单列索引-联合索引" class="headerlink" title="3.4.6 单列索引&amp;联合索引"></a>3.4.6 单列索引&amp;联合索引</h4><p>单列索引：即一个索引只包含单个列<br>联合索引：即一个索引包含了多个列<br>在业务场景中，如果存在多个查询条件，考虑针对于查询字段建立索引时，建议建立联合索引，而非单列索引。</p>
<p>单列索引情况：<br><code>explain select id, phone, name from tb_user where phone = &#39;17799990010&#39; and name = &#39;韩信&#39;;</code><br>这句只会用到phone索引字段</p>
<h5 id="注意事项-2"><a href="#注意事项-2" class="headerlink" title="注意事项"></a>注意事项</h5><ul>
<li>多条件联合查询时，MySQL优化器会评估哪个字段的索引效率更高，会选择该索引完成本次查询</li>
</ul>
<h3 id="3-5-设计原则"><a href="#3-5-设计原则" class="headerlink" title="3.5 设计原则"></a>3.5 设计原则</h3><ol>
<li>针对于数据量较大，且查询比较频繁的表建立索引</li>
<li>针对于常作为查询条件（where）、排序（order by）、分组（group by）操作的字段建立索引</li>
<li>尽量选择区分度高的列作为索引，尽量建立唯一索引，区分度越高，使用索引的效率越高</li>
<li>如果是字符串类型的字段，字段长度较长，可以针对于字段的特点，建立前缀索引</li>
<li>尽量使用联合索引，减少单列索引，查询时，联合索引很多时候可以覆盖索引，节省存储空间，避免回表，提高查询效率</li>
<li>要控制索引的数量，索引并不是多多益善，索引越多，维护索引结构的代价就越大，会影响增删改的效率</li>
<li>如果索引列不能存储NULL值，请在创建表时使用NOT NULL约束它。当优化器知道每列是否包含NULL值时，它可以更好地确定哪个索引最有效地用于查询</li>
</ol>
<h2 id="四-SQL-优化"><a href="#四-SQL-优化" class="headerlink" title="四.SQL 优化"></a>四.SQL 优化</h2><h3 id="4-1-插入数据"><a href="#4-1-插入数据" class="headerlink" title="4.1 插入数据"></a>4.1 插入数据</h3><p>普通插入：</p>
<ol>
<li>采用批量插入（一次插入的数据不建议超过1000条）</li>
<li>手动提交事务</li>
<li>主键顺序插入</li>
</ol>
<p>大批量插入：<br>如果一次性需要插入大批量数据，使用insert语句插入性能较低，此时可以使用MySQL数据库提供的load指令插入。</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"># 客户端连接服务端时，加上参数 --local-infile（这一行在bash/cmd界面输入）</span><br><span class="line">mysql --local-infile -u root -p</span><br><span class="line"># 设置全局参数local_infile为1，开启从本地加载文件导入数据的开关</span><br><span class="line">set global local_infile = 1;</span><br><span class="line">select @@local_infile;</span><br><span class="line"># 执行load指令将准备好的数据，加载到表结构中</span><br><span class="line">load data local infile &#x27;/root/sql1.log&#x27; into table &#x27;tb_user&#x27; fields terminated by &#x27;,&#x27; lines terminated by &#x27;\n&#x27;;</span><br></pre></td></tr></table></figure>

<h3 id="4-2-主键优化"><a href="#4-2-主键优化" class="headerlink" title="4.2 主键优化"></a>4.2 主键优化</h3><p>数据组织方式：在InnoDB存储引擎中，表数据都是根据主键顺序组织存放的，这种存储方式的表称为索引组织表（Index organized table, IOT）</p>
<p>页分裂：页可以为空，也可以填充一般，也可以填充100%，每个页包含了2-N行数据（如果一行数据过大，会行溢出），根据主键排列。<br>页合并：当删除一行记录时，实际上记录并没有被物理删除，只是记录被标记（flaged）为删除并且它的空间变得允许被其他记录声明使用。当页中删除的记录到达 MERGE_THRESHOLD（默认为页的50%），InnoDB会开始寻找最靠近的页（前后）看看是否可以将这两个页合并以优化空间使用。</p>
<p>MERGE_THRESHOLD：合并页的阈值，可以自己设置，在创建表或创建索引时指定</p>
<blockquote>
<p>文字说明不够清晰明了，具体可以看视频里的PPT演示过程：<a target="_blank" rel="noopener" href="https://www.bilibili.com/video/BV1Kr4y1i7ru?p=90">https://www.bilibili.com/video/BV1Kr4y1i7ru?p=90</a></p>
</blockquote>
<p>主键设计原则：</p>
<ul>
<li>满足业务需求的情况下，尽量降低主键的长度</li>
<li>插入数据时，尽量选择顺序插入，选择使用 AUTO_INCREMENT 自增主键</li>
<li>尽量不要使用 UUID 做主键或者是其他的自然主键，如身份证号</li>
<li>业务操作时，避免对主键的修改</li>
</ul>
<h3 id="4-3-order-by优化"><a href="#4-3-order-by优化" class="headerlink" title="4.3 order by优化"></a>4.3 order by优化</h3><ol>
<li>Using filesort：通过表的索引或全表扫描，读取满足条件的数据行，然后在排序缓冲区 sort buffer 中完成排序操作，所有不是通过索引直接返回排序结果的排序都叫 FileSort 排序</li>
<li>Using index：通过有序索引顺序扫描直接返回有序数据，这种情况即为 using index，不需要额外排序，操作效率高</li>
</ol>
<p>如果order by字段全部使用升序排序或者降序排序，则都会走索引，但是如果一个字段升序排序，另一个字段降序排序，则不会走索引，explain的extra信息显示的是<code>Using index, Using filesort</code>，如果要优化掉Using filesort，则需要另外再创建一个索引，如：<code>create index idx_user_age_phone_ad on tb_user(age asc, phone desc);</code>，此时使用<code>select id, age, phone from tb_user order by age asc, phone desc;</code>会全部走索引</p>
<p>总结：</p>
<ul>
<li>根据排序字段建立合适的索引，多字段排序时，也遵循最左前缀法则</li>
<li>尽量使用覆盖索引</li>
<li>多字段排序，一个升序一个降序，此时需要注意联合索引在创建时的规则（ASC&#x2F;DESC）</li>
<li>如果不可避免出现filesort，大数据量排序时，可以适当增大排序缓冲区大小 sort_buffer_size（默认256k）</li>
</ul>
<h3 id="4-5-group-by优化"><a href="#4-5-group-by优化" class="headerlink" title="4.5 group by优化"></a>4.5 group by优化</h3><ul>
<li>在分组操作时，可以通过索引来提高效率</li>
<li>分组操作时，索引的使用也是满足最左前缀法则的</li>
</ul>
<p>如索引为<code>idx_user_pro_age_stat</code>，则句式可以是<code>select ... where profession order by age</code>，这样也符合最左前缀法则</p>
<h3 id="4-6-limit优化"><a href="#4-6-limit优化" class="headerlink" title="4.6 limit优化"></a>4.6 limit优化</h3><p>常见的问题如<code>limit 2000000, 10</code>，此时需要 MySQL 排序前2000000条记录，但仅仅返回2000000 - 2000010的记录，其他记录丢弃，查询排序的代价非常大。<br>优化方案：一般分页查询时，通过创建覆盖索引能够比较好地提高性能，可以通过覆盖索引加子查询形式进行优化</p>
<p>例如：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">-- 此语句耗时很长</span><br><span class="line">select * from tb_sku limit 9000000, 10;</span><br><span class="line">-- 通过覆盖索引加快速度，直接通过主键索引进行排序及查询</span><br><span class="line">select id from tb_sku order by id limit 9000000, 10;</span><br><span class="line">-- 下面的语句是错误的，因为 MySQL 不支持 in 里面使用 limit</span><br><span class="line">-- select * from tb_sku where id in (select id from tb_sku order by id limit 9000000, 10);</span><br><span class="line">-- 通过连表查询即可实现第一句的效果，并且能达到第二句的速度</span><br><span class="line">select * from tb_sku as s, (select id from tb_sku order by id limit 9000000, 10) as a where s.id = a.id;</span><br></pre></td></tr></table></figure>

<h3 id="4-7-count优化"><a href="#4-7-count优化" class="headerlink" title="4.7 count优化"></a>4.7 count优化</h3><p>MyISAM 引擎把一个表的总行数存在了磁盘上，因此执行 count(*) 的时候会直接返回这个数，效率很高（前提是不适用where）；<br>InnoDB 在执行 count(*) 时，需要把数据一行一行地从引擎里面读出来，然后累计计数。<br>优化方案：自己计数，如创建key-value表存储在内存或硬盘，或者是用redis</p>
<p>count的几种用法：</p>
<ul>
<li>如果count函数的参数（count里面写的那个字段）不是NULL（字段值不为NULL），累计值就加一，最后返回累计值</li>
<li>用法：count(*)、count(主键)、count(字段)、count(1)</li>
<li>count(主键)跟count(*)一样，因为主键不能为空；count(字段)只计算字段值不为NULL的行；count(1)引擎会为每行添加一个1，然后就count这个1，返回结果也跟count(*)一样；count(null)返回0</li>
</ul>
<p>各种用法的性能：</p>
<ul>
<li>count(主键)：InnoDB引擎会遍历整张表，把每行的主键id值都取出来，返回给服务层，服务层拿到主键后，直接按行进行累加（主键不可能为空）</li>
<li>count(字段)：没有not null约束的话，InnoDB引擎会遍历整张表把每一行的字段值都取出来，返回给服务层，服务层判断是否为null，不为null，计数累加；有not null约束的话，InnoDB引擎会遍历整张表把每一行的字段值都取出来，返回给服务层，直接按行进行累加</li>
<li>count(1)：InnoDB 引擎遍历整张表，但不取值。服务层对于返回的每一层，放一个数字 1 进去，直接按行进行累加</li>
<li>count(*)：InnoDB 引擎并不会把全部字段取出来，而是专门做了优化，不取值，服务层直接按行进行累加</li>
</ul>
<p>按效率排序：count(字段) &lt; count(主键) &lt; count(1) &lt; count(*)，所以尽量使用 count(*)</p>
<h3 id="4-8-update优化（避免行锁升级为表锁）"><a href="#4-8-update优化（避免行锁升级为表锁）" class="headerlink" title="4.8 update优化（避免行锁升级为表锁）"></a>4.8 update优化（避免行锁升级为表锁）</h3><p>InnoDB 的行锁是针对索引加的锁，不是针对记录加的锁，并且该索引不能失效，否则会从行锁升级为表锁。</p>
<p>如以下两条语句：<br><code>update student set no = &#39;123&#39; where id = 1;</code>，这句由于id有主键索引，所以只会锁这一行；<br><code>update student set no = &#39;123&#39; where name = &#39;test&#39;;</code>，这句由于name没有索引，所以会把整张表都锁住进行数据更新，解决方法是给name字段添加索引</p>
<h1 id="数据类型汇总"><a href="#数据类型汇总" class="headerlink" title="数据类型汇总"></a>数据类型汇总</h1><h2 id="一-整型"><a href="#一-整型" class="headerlink" title="一.整型"></a>一.整型</h2><table>
<thead>
<tr>
<th align="center">类型名称</th>
<th align="center">取值范围</th>
<th align="center">大小</th>
</tr>
</thead>
<tbody><tr>
<td align="center">TINYINT</td>
<td align="center">-128〜127</td>
<td align="center">1个字节</td>
</tr>
<tr>
<td align="center">SMALLINT</td>
<td align="center">-32768〜32767</td>
<td align="center">2个宇节</td>
</tr>
<tr>
<td align="center">MEDIUMINT</td>
<td align="center">-8388608〜8388607</td>
<td align="center">3个字节</td>
</tr>
<tr>
<td align="center">INT (INTEGHR)</td>
<td align="center">-2147483648〜2147483647</td>
<td align="center">4个字节</td>
</tr>
<tr>
<td align="center">BIGINT</td>
<td align="center">-9223372036854775808〜9223372036854775807</td>
<td align="center">8个字节</td>
</tr>
</tbody></table>
<p>无符号在数据类型后加 unsigned 关键字。</p>
<h2 id="二-浮点型"><a href="#二-浮点型" class="headerlink" title="二.浮点型"></a>二.浮点型</h2><table>
<thead>
<tr>
<th align="center">类型名称</th>
<th align="center">说明</th>
<th align="center">存储需求</th>
</tr>
</thead>
<tbody><tr>
<td align="center">FLOAT</td>
<td align="center">单精度浮点数</td>
<td align="center">4 个字节</td>
</tr>
<tr>
<td align="center">DOUBLE</td>
<td align="center">双精度浮点数</td>
<td align="center">8 个字节</td>
</tr>
<tr>
<td align="center">DECIMAL (M, D)，DEC</td>
<td align="center">压缩的“严格”定点数</td>
<td align="center">M+2 个字节</td>
</tr>
</tbody></table>
<h2 id="三-日期和时间"><a href="#三-日期和时间" class="headerlink" title="三.日期和时间"></a>三.日期和时间</h2><table>
<thead>
<tr>
<th align="center">类型名称</th>
<th align="center">日期格式</th>
<th align="center">日期范围</th>
<th align="center">存储需求</th>
</tr>
</thead>
<tbody><tr>
<td align="center">YEAR</td>
<td align="center">YYYY</td>
<td align="center">1901 ~ 2155</td>
<td align="center">1 个字节</td>
</tr>
<tr>
<td align="center">TIME</td>
<td align="center">HH:MM:SS</td>
<td align="center">-838:59:59 ~ 838:59:59</td>
<td align="center">3 个字节</td>
</tr>
<tr>
<td align="center">DATE</td>
<td align="center">YYYY-MM-DD</td>
<td align="center">1000-01-01 ~ 9999-12-3</td>
<td align="center">3 个字节</td>
</tr>
<tr>
<td align="center">DATETIME</td>
<td align="center">YYYY-MM-DD HH:MM:SS</td>
<td align="center">1000-01-01 00:00:00 ~ 9999-12-31 23:59:59</td>
<td align="center">8 个字节</td>
</tr>
<tr>
<td align="center">TIMESTAMP</td>
<td align="center">YYYY-MM-DD HH:MM:SS</td>
<td align="center">1980-01-01 00:00:01 UTC ~ 2040-01-19 03:14:07 UTC</td>
<td align="center">4 个字节</td>
</tr>
</tbody></table>
<h2 id="四-字符串"><a href="#四-字符串" class="headerlink" title="四.字符串"></a>四.字符串</h2><table>
<thead>
<tr>
<th align="center">类型名称</th>
<th align="center">说明</th>
<th align="center">存储需求</th>
</tr>
</thead>
<tbody><tr>
<td align="center">CHAR(M)</td>
<td align="center">固定长度非二进制字符串</td>
<td align="center">M 字节，1&lt;&#x3D;M&lt;&#x3D;255</td>
</tr>
<tr>
<td align="center">VARCHAR(M)</td>
<td align="center">变长非二进制字符串</td>
<td align="center">L+1字节，在此，L&lt; &#x3D; M和 1&lt;&#x3D;M&lt;&#x3D;255</td>
</tr>
<tr>
<td align="center">TINYTEXT</td>
<td align="center">非常小的非二进制字符串</td>
<td align="center">L+1字节，在此，L&lt;2^8</td>
</tr>
<tr>
<td align="center">TEXT</td>
<td align="center">小的非二进制字符串</td>
<td align="center">L+2字节，在此，L&lt;2^16</td>
</tr>
<tr>
<td align="center">MEDIUMTEXT</td>
<td align="center">中等大小的非二进制字符串</td>
<td align="center">L+3字节，在此，L&lt;2^24</td>
</tr>
<tr>
<td align="center">LONGTEXT</td>
<td align="center">大的非二进制字符串</td>
<td align="center">L+4字节，在此，L&lt;2^32</td>
</tr>
<tr>
<td align="center">ENUM</td>
<td align="center">枚举类型，只能有一个枚举字符串值</td>
<td align="center">1或2个字节，取决于枚举值的数目 (最大值为65535)</td>
</tr>
<tr>
<td align="center">SET</td>
<td align="center">一个设置，字符串对象可以有零个或 多个SET成员</td>
<td align="center">1、2、3、4或8个字节，取决于集合 成员的数量（最多64个成员）</td>
</tr>
</tbody></table>
<h2 id="五-二进制类型"><a href="#五-二进制类型" class="headerlink" title="五.二进制类型"></a>五.二进制类型</h2><table>
<thead>
<tr>
<th align="center">类型名称</th>
<th align="center">说明</th>
<th align="center">存储需求</th>
</tr>
</thead>
<tbody><tr>
<td align="center">BIT(M)</td>
<td align="center">位字段类型</td>
<td align="center">大约 (M+7)&#x2F;8 字节</td>
</tr>
<tr>
<td align="center">BINARY(M)</td>
<td align="center">固定长度二进制字符串</td>
<td align="center">M 字节</td>
</tr>
<tr>
<td align="center">VARBINARY (M)</td>
<td align="center">可变长度二进制字符串</td>
<td align="center">M+1 字节</td>
</tr>
<tr>
<td align="center">TINYBLOB (M)</td>
<td align="center">非常小的BLOB</td>
<td align="center">L+1 字节，在此，L&lt;2^8</td>
</tr>
<tr>
<td align="center">BLOB (M)</td>
<td align="center">小 BLOB</td>
<td align="center">L+2 字节，在此，L&lt;2^16</td>
</tr>
<tr>
<td align="center">MEDIUMBLOB (M)</td>
<td align="center">中等大小的BLOB</td>
<td align="center">L+3 字节，在此，L&lt;2^24</td>
</tr>
<tr>
<td align="center">LONGBLOB (M)</td>
<td align="center">非常大的BLOB</td>
<td align="center">L+4 字节，在此，L&lt;2^32</td>
</tr>
</tbody></table>
<h1 id="权限一览表"><a href="#权限一览表" class="headerlink" title="权限一览表"></a>权限一览表</h1><blockquote>
<p>具体权限的作用详见<a target="_blank" rel="noopener" href="https://dev.mysql.com/doc/refman/8.0/en/privileges-provided.html" title="官方文档">官方文档</a></p>
</blockquote>
<p>GRANT 和 REVOKE 允许的静态权限</p>
<table>
<thead>
<tr>
<th align="center">Privilege</th>
<th align="center">Grant Table Column</th>
<th align="center">Context</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><a target="_blank" rel="noopener" href="https://dev.mysql.com/doc/refman/8.0/en/privileges-provided.html#priv_all"><code>ALL [PRIVILEGES]</code></a></td>
<td align="center">Synonym for “all privileges”</td>
<td align="center">Server administration</td>
</tr>
<tr>
<td align="center"><a target="_blank" rel="noopener" href="https://dev.mysql.com/doc/refman/8.0/en/privileges-provided.html#priv_alter"><code>ALTER</code></a></td>
<td align="center"><code>Alter_priv</code></td>
<td align="center">Tables</td>
</tr>
<tr>
<td align="center"><a target="_blank" rel="noopener" href="https://dev.mysql.com/doc/refman/8.0/en/privileges-provided.html#priv_alter-routine"><code>ALTER ROUTINE</code></a></td>
<td align="center"><code>Alter_routine_priv</code></td>
<td align="center">Stored routines</td>
</tr>
<tr>
<td align="center"><a target="_blank" rel="noopener" href="https://dev.mysql.com/doc/refman/8.0/en/privileges-provided.html#priv_create"><code>CREATE</code></a></td>
<td align="center"><code>Create_priv</code></td>
<td align="center">Databases, tables, or indexes</td>
</tr>
<tr>
<td align="center"><a target="_blank" rel="noopener" href="https://dev.mysql.com/doc/refman/8.0/en/privileges-provided.html#priv_create-role"><code>CREATE ROLE</code></a></td>
<td align="center"><code>Create_role_priv</code></td>
<td align="center">Server administration</td>
</tr>
<tr>
<td align="center"><a target="_blank" rel="noopener" href="https://dev.mysql.com/doc/refman/8.0/en/privileges-provided.html#priv_create-routine"><code>CREATE ROUTINE</code></a></td>
<td align="center"><code>Create_routine_priv</code></td>
<td align="center">Stored routines</td>
</tr>
<tr>
<td align="center"><a target="_blank" rel="noopener" href="https://dev.mysql.com/doc/refman/8.0/en/privileges-provided.html#priv_create-tablespace"><code>CREATE TABLESPACE</code></a></td>
<td align="center"><code>Create_tablespace_priv</code></td>
<td align="center">Server administration</td>
</tr>
<tr>
<td align="center"><a target="_blank" rel="noopener" href="https://dev.mysql.com/doc/refman/8.0/en/privileges-provided.html#priv_create-temporary-tables"><code>CREATE TEMPORARY TABLES</code></a></td>
<td align="center"><code>Create_tmp_table_priv</code></td>
<td align="center">Tables</td>
</tr>
<tr>
<td align="center"><a target="_blank" rel="noopener" href="https://dev.mysql.com/doc/refman/8.0/en/privileges-provided.html#priv_create-user"><code>CREATE USER</code></a></td>
<td align="center"><code>Create_user_priv</code></td>
<td align="center">Server administration</td>
</tr>
<tr>
<td align="center"><a target="_blank" rel="noopener" href="https://dev.mysql.com/doc/refman/8.0/en/privileges-provided.html#priv_create-view"><code>CREATE VIEW</code></a></td>
<td align="center"><code>Create_view_priv</code></td>
<td align="center">Views</td>
</tr>
<tr>
<td align="center"><a target="_blank" rel="noopener" href="https://dev.mysql.com/doc/refman/8.0/en/privileges-provided.html#priv_delete"><code>DELETE</code></a></td>
<td align="center"><code>Delete_priv</code></td>
<td align="center">Tables</td>
</tr>
<tr>
<td align="center"><a target="_blank" rel="noopener" href="https://dev.mysql.com/doc/refman/8.0/en/privileges-provided.html#priv_drop"><code>DROP</code></a></td>
<td align="center"><code>Drop_priv</code></td>
<td align="center">Databases, tables, or views</td>
</tr>
<tr>
<td align="center"><a target="_blank" rel="noopener" href="https://dev.mysql.com/doc/refman/8.0/en/privileges-provided.html#priv_drop-role"><code>DROP ROLE</code></a></td>
<td align="center"><code>Drop_role_priv</code></td>
<td align="center">Server administration</td>
</tr>
<tr>
<td align="center"><a target="_blank" rel="noopener" href="https://dev.mysql.com/doc/refman/8.0/en/privileges-provided.html#priv_event"><code>EVENT</code></a></td>
<td align="center"><code>Event_priv</code></td>
<td align="center">Databases</td>
</tr>
<tr>
<td align="center"><a target="_blank" rel="noopener" href="https://dev.mysql.com/doc/refman/8.0/en/privileges-provided.html#priv_execute"><code>EXECUTE</code></a></td>
<td align="center"><code>Execute_priv</code></td>
<td align="center">Stored routines</td>
</tr>
<tr>
<td align="center"><a target="_blank" rel="noopener" href="https://dev.mysql.com/doc/refman/8.0/en/privileges-provided.html#priv_file"><code>FILE</code></a></td>
<td align="center"><code>File_priv</code></td>
<td align="center">File access on server host</td>
</tr>
<tr>
<td align="center"><a target="_blank" rel="noopener" href="https://dev.mysql.com/doc/refman/8.0/en/privileges-provided.html#priv_grant-option"><code>GRANT OPTION</code></a></td>
<td align="center"><code>Grant_priv</code></td>
<td align="center">Databases, tables, or stored routines</td>
</tr>
<tr>
<td align="center"><a target="_blank" rel="noopener" href="https://dev.mysql.com/doc/refman/8.0/en/privileges-provided.html#priv_index"><code>INDEX</code></a></td>
<td align="center"><code>Index_priv</code></td>
<td align="center">Tables</td>
</tr>
<tr>
<td align="center"><a target="_blank" rel="noopener" href="https://dev.mysql.com/doc/refman/8.0/en/privileges-provided.html#priv_insert"><code>INSERT</code></a></td>
<td align="center"><code>Insert_priv</code></td>
<td align="center">Tables or columns</td>
</tr>
<tr>
<td align="center"><a target="_blank" rel="noopener" href="https://dev.mysql.com/doc/refman/8.0/en/privileges-provided.html#priv_lock-tables"><code>LOCK TABLES</code></a></td>
<td align="center"><code>Lock_tables_priv</code></td>
<td align="center">Databases</td>
</tr>
<tr>
<td align="center"><a target="_blank" rel="noopener" href="https://dev.mysql.com/doc/refman/8.0/en/privileges-provided.html#priv_process"><code>PROCESS</code></a></td>
<td align="center"><code>Process_priv</code></td>
<td align="center">Server administration</td>
</tr>
<tr>
<td align="center"><a target="_blank" rel="noopener" href="https://dev.mysql.com/doc/refman/8.0/en/privileges-provided.html#priv_proxy"><code>PROXY</code></a></td>
<td align="center">See <code>proxies_priv</code> table</td>
<td align="center">Server administration</td>
</tr>
<tr>
<td align="center"><a target="_blank" rel="noopener" href="https://dev.mysql.com/doc/refman/8.0/en/privileges-provided.html#priv_references"><code>REFERENCES</code></a></td>
<td align="center"><code>References_priv</code></td>
<td align="center">Databases or tables</td>
</tr>
<tr>
<td align="center"><a target="_blank" rel="noopener" href="https://dev.mysql.com/doc/refman/8.0/en/privileges-provided.html#priv_reload"><code>RELOAD</code></a></td>
<td align="center"><code>Reload_priv</code></td>
<td align="center">Server administration</td>
</tr>
<tr>
<td align="center"><a target="_blank" rel="noopener" href="https://dev.mysql.com/doc/refman/8.0/en/privileges-provided.html#priv_replication-client"><code>REPLICATION CLIENT</code></a></td>
<td align="center"><code>Repl_client_priv</code></td>
<td align="center">Server administration</td>
</tr>
<tr>
<td align="center"><a target="_blank" rel="noopener" href="https://dev.mysql.com/doc/refman/8.0/en/privileges-provided.html#priv_replication-slave"><code>REPLICATION SLAVE</code></a></td>
<td align="center"><code>Repl_slave_priv</code></td>
<td align="center">Server administration</td>
</tr>
<tr>
<td align="center"><a target="_blank" rel="noopener" href="https://dev.mysql.com/doc/refman/8.0/en/privileges-provided.html#priv_select"><code>SELECT</code></a></td>
<td align="center"><code>Select_priv</code></td>
<td align="center">Tables or columns</td>
</tr>
<tr>
<td align="center"><a target="_blank" rel="noopener" href="https://dev.mysql.com/doc/refman/8.0/en/privileges-provided.html#priv_show-databases"><code>SHOW DATABASES</code></a></td>
<td align="center"><code>Show_db_priv</code></td>
<td align="center">Server administration</td>
</tr>
<tr>
<td align="center"><a target="_blank" rel="noopener" href="https://dev.mysql.com/doc/refman/8.0/en/privileges-provided.html#priv_show-view"><code>SHOW VIEW</code></a></td>
<td align="center"><code>Show_view_priv</code></td>
<td align="center">Views</td>
</tr>
<tr>
<td align="center"><a target="_blank" rel="noopener" href="https://dev.mysql.com/doc/refman/8.0/en/privileges-provided.html#priv_shutdown"><code>SHUTDOWN</code></a></td>
<td align="center"><code>Shutdown_priv</code></td>
<td align="center">Server administration</td>
</tr>
<tr>
<td align="center"><a target="_blank" rel="noopener" href="https://dev.mysql.com/doc/refman/8.0/en/privileges-provided.html#priv_super"><code>SUPER</code></a></td>
<td align="center"><code>Super_priv</code></td>
<td align="center">Server administration</td>
</tr>
<tr>
<td align="center"><a target="_blank" rel="noopener" href="https://dev.mysql.com/doc/refman/8.0/en/privileges-provided.html#priv_trigger"><code>TRIGGER</code></a></td>
<td align="center"><code>Trigger_priv</code></td>
<td align="center">Tables</td>
</tr>
<tr>
<td align="center"><a target="_blank" rel="noopener" href="https://dev.mysql.com/doc/refman/8.0/en/privileges-provided.html#priv_update"><code>UPDATE</code></a></td>
<td align="center"><code>Update_priv</code></td>
<td align="center">Tables or columns</td>
</tr>
<tr>
<td align="center"><a target="_blank" rel="noopener" href="https://dev.mysql.com/doc/refman/8.0/en/privileges-provided.html#priv_usage"><code>USAGE</code></a></td>
<td align="center">Synonym for “no privileges”</td>
<td align="center">Server administration</td>
</tr>
</tbody></table>
<p>GRANT 和 REVOKE 允许的动态权限</p>
<table>
<thead>
<tr>
<th align="center">Privilege</th>
<th align="center">Context</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><a target="_blank" rel="noopener" href="https://dev.mysql.com/doc/refman/8.0/en/privileges-provided.html#priv_application-password-admin"><code>APPLICATION_PASSWORD_ADMIN</code></a></td>
<td align="center">Dual password administration</td>
</tr>
<tr>
<td align="center"><a target="_blank" rel="noopener" href="https://dev.mysql.com/doc/refman/8.0/en/privileges-provided.html#priv_audit-abort-exempt"><code>AUDIT_ABORT_EXEMPT</code></a></td>
<td align="center">Allow queries blocked by audit log filter</td>
</tr>
<tr>
<td align="center"><a target="_blank" rel="noopener" href="https://dev.mysql.com/doc/refman/8.0/en/privileges-provided.html#priv_audit-admin"><code>AUDIT_ADMIN</code></a></td>
<td align="center">Audit log administration</td>
</tr>
<tr>
<td align="center"><a target="_blank" rel="noopener" href="https://dev.mysql.com/doc/refman/8.0/en/privileges-provided.html#priv_authentication-policy-admin"><code>AUTHENTICATION_POLICY_ADMIN</code></a></td>
<td align="center">Authentication administration</td>
</tr>
<tr>
<td align="center"><a target="_blank" rel="noopener" href="https://dev.mysql.com/doc/refman/8.0/en/privileges-provided.html#priv_backup-admin"><code>BACKUP_ADMIN</code></a></td>
<td align="center">Backup administration</td>
</tr>
<tr>
<td align="center"><a target="_blank" rel="noopener" href="https://dev.mysql.com/doc/refman/8.0/en/privileges-provided.html#priv_binlog-admin"><code>BINLOG_ADMIN</code></a></td>
<td align="center">Backup and Replication administration</td>
</tr>
<tr>
<td align="center"><a target="_blank" rel="noopener" href="https://dev.mysql.com/doc/refman/8.0/en/privileges-provided.html#priv_binlog-encryption-admin"><code>BINLOG_ENCRYPTION_ADMIN</code></a></td>
<td align="center">Backup and Replication administration</td>
</tr>
<tr>
<td align="center"><a target="_blank" rel="noopener" href="https://dev.mysql.com/doc/refman/8.0/en/privileges-provided.html#priv_clone-admin"><code>CLONE_ADMIN</code></a></td>
<td align="center">Clone administration</td>
</tr>
<tr>
<td align="center"><a target="_blank" rel="noopener" href="https://dev.mysql.com/doc/refman/8.0/en/privileges-provided.html#priv_connection-admin"><code>CONNECTION_ADMIN</code></a></td>
<td align="center">Server administration</td>
</tr>
<tr>
<td align="center"><a target="_blank" rel="noopener" href="https://dev.mysql.com/doc/refman/8.0/en/privileges-provided.html#priv_encryption-key-admin"><code>ENCRYPTION_KEY_ADMIN</code></a></td>
<td align="center">Server administration</td>
</tr>
<tr>
<td align="center"><a target="_blank" rel="noopener" href="https://dev.mysql.com/doc/refman/8.0/en/privileges-provided.html#priv_firewall-admin"><code>FIREWALL_ADMIN</code></a></td>
<td align="center">Firewall administration</td>
</tr>
<tr>
<td align="center"><a target="_blank" rel="noopener" href="https://dev.mysql.com/doc/refman/8.0/en/privileges-provided.html#priv_firewall-exempt"><code>FIREWALL_EXEMPT</code></a></td>
<td align="center">Firewall administration</td>
</tr>
<tr>
<td align="center"><a target="_blank" rel="noopener" href="https://dev.mysql.com/doc/refman/8.0/en/privileges-provided.html#priv_firewall-user"><code>FIREWALL_USER</code></a></td>
<td align="center">Firewall administration</td>
</tr>
<tr>
<td align="center"><a target="_blank" rel="noopener" href="https://dev.mysql.com/doc/refman/8.0/en/privileges-provided.html#priv_flush-optimizer-costs"><code>FLUSH_OPTIMIZER_COSTS</code></a></td>
<td align="center">Server administration</td>
</tr>
<tr>
<td align="center"><a target="_blank" rel="noopener" href="https://dev.mysql.com/doc/refman/8.0/en/privileges-provided.html#priv_flush-status"><code>FLUSH_STATUS</code></a></td>
<td align="center">Server administration</td>
</tr>
<tr>
<td align="center"><a target="_blank" rel="noopener" href="https://dev.mysql.com/doc/refman/8.0/en/privileges-provided.html#priv_flush-tables"><code>FLUSH_TABLES</code></a></td>
<td align="center">Server administration</td>
</tr>
<tr>
<td align="center"><a target="_blank" rel="noopener" href="https://dev.mysql.com/doc/refman/8.0/en/privileges-provided.html#priv_flush-user-resources"><code>FLUSH_USER_RESOURCES</code></a></td>
<td align="center">Server administration</td>
</tr>
<tr>
<td align="center"><a target="_blank" rel="noopener" href="https://dev.mysql.com/doc/refman/8.0/en/privileges-provided.html#priv_group-replication-admin"><code>GROUP_REPLICATION_ADMIN</code></a></td>
<td align="center">Replication administration</td>
</tr>
<tr>
<td align="center"><a target="_blank" rel="noopener" href="https://dev.mysql.com/doc/refman/8.0/en/privileges-provided.html#priv_group-replication-stream"><code>GROUP_REPLICATION_STREAM</code></a></td>
<td align="center">Replication administration</td>
</tr>
<tr>
<td align="center"><a target="_blank" rel="noopener" href="https://dev.mysql.com/doc/refman/8.0/en/privileges-provided.html#priv_innodb-redo-log-archive"><code>INNODB_REDO_LOG_ARCHIVE</code></a></td>
<td align="center">Redo log archiving administration</td>
</tr>
<tr>
<td align="center"><a target="_blank" rel="noopener" href="https://dev.mysql.com/doc/refman/8.0/en/privileges-provided.html#priv_ndb-stored-user"><code>NDB_STORED_USER</code></a></td>
<td align="center">NDB Cluster</td>
</tr>
<tr>
<td align="center"><a target="_blank" rel="noopener" href="https://dev.mysql.com/doc/refman/8.0/en/privileges-provided.html#priv_passwordless-user-admin"><code>PASSWORDLESS_USER_ADMIN</code></a></td>
<td align="center">Authentication administration</td>
</tr>
<tr>
<td align="center"><a target="_blank" rel="noopener" href="https://dev.mysql.com/doc/refman/8.0/en/privileges-provided.html#priv_persist-ro-variables-admin"><code>PERSIST_RO_VARIABLES_ADMIN</code></a></td>
<td align="center">Server administration</td>
</tr>
<tr>
<td align="center"><a target="_blank" rel="noopener" href="https://dev.mysql.com/doc/refman/8.0/en/privileges-provided.html#priv_replication-applier"><code>REPLICATION_APPLIER</code></a></td>
<td align="center"><code>PRIVILEGE_CHECKS_USER</code> for a replication channel</td>
</tr>
<tr>
<td align="center"><a target="_blank" rel="noopener" href="https://dev.mysql.com/doc/refman/8.0/en/privileges-provided.html#priv_replication-slave-admin"><code>REPLICATION_SLAVE_ADMIN</code></a></td>
<td align="center">Replication administration</td>
</tr>
<tr>
<td align="center"><a target="_blank" rel="noopener" href="https://dev.mysql.com/doc/refman/8.0/en/privileges-provided.html#priv_resource-group-admin"><code>RESOURCE_GROUP_ADMIN</code></a></td>
<td align="center">Resource group administration</td>
</tr>
<tr>
<td align="center"><a target="_blank" rel="noopener" href="https://dev.mysql.com/doc/refman/8.0/en/privileges-provided.html#priv_resource-group-user"><code>RESOURCE_GROUP_USER</code></a></td>
<td align="center">Resource group administration</td>
</tr>
<tr>
<td align="center"><a target="_blank" rel="noopener" href="https://dev.mysql.com/doc/refman/8.0/en/privileges-provided.html#priv_role-admin"><code>ROLE_ADMIN</code></a></td>
<td align="center">Server administration</td>
</tr>
<tr>
<td align="center"><a target="_blank" rel="noopener" href="https://dev.mysql.com/doc/refman/8.0/en/privileges-provided.html#priv_session-variables-admin"><code>SESSION_VARIABLES_ADMIN</code></a></td>
<td align="center">Server administration</td>
</tr>
<tr>
<td align="center"><a target="_blank" rel="noopener" href="https://dev.mysql.com/doc/refman/8.0/en/privileges-provided.html#priv_set-user-id"><code>SET_USER_ID</code></a></td>
<td align="center">Server administration</td>
</tr>
<tr>
<td align="center"><a target="_blank" rel="noopener" href="https://dev.mysql.com/doc/refman/8.0/en/privileges-provided.html#priv_show-routine"><code>SHOW_ROUTINE</code></a></td>
<td align="center">Server administration</td>
</tr>
<tr>
<td align="center"><a target="_blank" rel="noopener" href="https://dev.mysql.com/doc/refman/8.0/en/privileges-provided.html#priv_system-user"><code>SYSTEM_USER</code></a></td>
<td align="center">Server administration</td>
</tr>
<tr>
<td align="center"><a target="_blank" rel="noopener" href="https://dev.mysql.com/doc/refman/8.0/en/privileges-provided.html#priv_system-variables-admin"><code>SYSTEM_VARIABLES_ADMIN</code></a></td>
<td align="center">Server administration</td>
</tr>
<tr>
<td align="center"><a target="_blank" rel="noopener" href="https://dev.mysql.com/doc/refman/8.0/en/privileges-provided.html#priv_table-encryption-admin"><code>TABLE_ENCRYPTION_ADMIN</code></a></td>
<td align="center">Server administration</td>
</tr>
<tr>
<td align="center"><a target="_blank" rel="noopener" href="https://dev.mysql.com/doc/refman/8.0/en/privileges-provided.html#priv_version-token-admin"><code>VERSION_TOKEN_ADMIN</code></a></td>
<td align="center">Server administration</td>
</tr>
<tr>
<td align="center"><a target="_blank" rel="noopener" href="https://dev.mysql.com/doc/refman/8.0/en/privileges-provided.html#priv_xa-recover-admin"><code>XA_RECOVER_ADMIN</code></a></td>
<td align="center">Server administration</td>
</tr>
</tbody></table>
<h1 id="图形化界面工具"><a href="#图形化界面工具" class="headerlink" title="图形化界面工具"></a>图形化界面工具</h1><ul>
<li>Workbench(免费): <a target="_blank" rel="noopener" href="http://dev.mysql.com/downloads/workbench/">http://dev.mysql.com/downloads/workbench/</a></li>
<li>navicat(收费，试用版30天): <a target="_blank" rel="noopener" href="https://www.navicat.com/en/download/navicat-for-mysql">https://www.navicat.com/en/download/navicat-for-mysql</a></li>
<li>Sequel Pro(开源免费，仅支持Mac OS): <a target="_blank" rel="noopener" href="http://www.sequelpro.com/">http://www.sequelpro.com/</a></li>
<li>HeidiSQL(免费): <a target="_blank" rel="noopener" href="http://www.heidisql.com/">http://www.heidisql.com/</a></li>
<li>phpMyAdmin(免费): <a target="_blank" rel="noopener" href="https://www.phpmyadmin.net/">https://www.phpmyadmin.net/</a></li>
<li>SQLyog: <a target="_blank" rel="noopener" href="https://sqlyog.en.softonic.com/">https://sqlyog.en.softonic.com/</a></li>
</ul>
<h1 id="安装"><a href="#安装" class="headerlink" title="安装"></a>安装</h1><h1 id="小技巧"><a href="#小技巧" class="headerlink" title="小技巧"></a>小技巧</h1><ol>
<li>在SQL语句之后加上<code>\G</code>会将结果的表格形式转换成行文本形式</li>
<li>查看Mysql数据库占用空间：<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">SELECT table_schema &quot;Database Name&quot;</span><br><span class="line">     , SUM(data_length + index_length) / (1024 * 1024) &quot;Database Size in MB&quot;</span><br><span class="line">FROM information_schema.TABLES</span><br><span class="line">GROUP BY table_schema;</span><br></pre></td></tr></table></figure></li>
</ol>

      

      
    </div>
    <div class="article-info article-info-index">
      
      
	<div class="article-tag tagcloud">
		<i class="icon-price-tags icon"></i>
		<ul class="article-tag-list">
			 
        		<li class="article-tag-list-item">
        			<a href="javascript:void(0)" class="js-tag article-tag-list-link color1">MySql</a>
        		</li>
      		
		</ul>
	</div>

      

      
        <p class="article-more-link">
          <a class="article-more-a" href="/2022/08/31/MySQL%E5%AD%A6%E4%B9%A0/">展开全文 >></a>
        </p>
      

      
      <div class="clearfix"></div>
    </div>
  </div>
</article>

<aside class="wrap-side-operation">
    <div class="mod-side-operation">
        
        <div class="jump-container" id="js-jump-container" style="display:none;">
            <a href="javascript:void(0)" class="mod-side-operation__jump-to-top">
                <i class="icon-font icon-back"></i>
            </a>
            <div id="js-jump-plan-container" class="jump-plan-container" style="top: -11px;">
                <i class="icon-font icon-plane jump-plane"></i>
            </div>
        </div>
        
        
    </div>
</aside>




  
    <article id="post-常用Linux命令" class="article article-type-post  article-index" itemscope itemprop="blogPost">
  <div class="article-inner">
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/2022/07/29/%E5%B8%B8%E7%94%A8Linux%E5%91%BD%E4%BB%A4/">常用Linux命令</a>
    </h1>
  

        
        <a href="/2022/07/29/%E5%B8%B8%E7%94%A8Linux%E5%91%BD%E4%BB%A4/" class="archive-article-date">
  	<time datetime="2022-07-29T06:46:31.000Z" itemprop="datePublished"><i class="icon-calendar icon"></i>2022-07-29</time>
</a>
        
      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <h1 id="常用Linux命令"><a href="#常用Linux命令" class="headerlink" title="常用Linux命令"></a>常用Linux命令</h1><h2 id="一-目录操作"><a href="#一-目录操作" class="headerlink" title="一.目录操作"></a>一.目录操作</h2><h3 id="1-1-基本命令"><a href="#1-1-基本命令" class="headerlink" title="1.1 基本命令"></a>1.1 基本命令</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">pwd 	# 查看当前⼯作⽬录</span><br><span class="line">clear 	# 清除屏幕</span><br><span class="line">cd ~ 	# 当前⽤户⽬录</span><br><span class="line">cd / 	# 根⽬录</span><br><span class="line">cd - 	# 上⼀次访问的⽬录</span><br><span class="line">cd .. 	# 上⼀级⽬录</span><br></pre></td></tr></table></figure>

<h3 id="1-2-查看目录内信息"><a href="#1-2-查看目录内信息" class="headerlink" title="1.2 查看目录内信息"></a>1.2 查看目录内信息</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">ll 		# 查看当前⽬录下内容（LL的⼩写）</span><br></pre></td></tr></table></figure>

<h3 id="1-3-创建目录"><a href="#1-3-创建目录" class="headerlink" title="1.3 创建目录"></a>1.3 创建目录</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">mkdir aaa 			 # 在当前⽬录下创建aaa⽬录，相对路径；</span><br><span class="line">mkdir ./bbb 		 # 在当前⽬录下创建bbb⽬录，相对路径；</span><br><span class="line">mkdir /ccc 			 # 在根⽬录下创建ccc⽬录，绝对路径；</span><br><span class="line">mkdir -p temp/nginx	  # 递归创建目录（会创建⾥⾯没有的⽬录⽂件夹）</span><br></pre></td></tr></table></figure>

<h3 id="1-4-搜索命令"><a href="#1-4-搜索命令" class="headerlink" title="1.4 搜索命令"></a>1.4 搜索命令</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">find / -name &#x27;b&#x27; 	# 查询根⽬录下（包括⼦⽬录），名以b的⽬录和⽂件；</span><br><span class="line">find / -name &#x27;b*&#x27; 	# 查询根⽬录下（包括⼦⽬录），名以b开头的⽬录和⽂件；</span><br></pre></td></tr></table></figure>

<h3 id="1-5-重命名"><a href="#1-5-重命名" class="headerlink" title="1.5 重命名"></a>1.5 重命名</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">mv 原先⽬录 ⽂件的名称 	# 举例：mv tomcat001 tomcat</span><br></pre></td></tr></table></figure>

<h3 id="1-6-剪切命令"><a href="#1-6-剪切命令" class="headerlink" title="1.6 剪切命令"></a>1.6 剪切命令</h3><blockquote>
<p>有⽬录剪切到制定⽬录下，没有的话剪切为指定⽬录</p>
</blockquote>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">mv /aaa /bbb		# 将根⽬录下的aaa⽬录，移动到bbb⽬录下，在bbb，麚也叫aaa⽬录；</span><br><span class="line">mv bbbb usr/bbb 	# 将当前⽬录下的bbbb⽬录，移动到usr⽬录下，并且修改名称为bbb；</span><br><span class="line">mv bbb usr/aaa 		# 将当前⽬录下的bbbb⽬录，移动到usr⽬录下，并且修改名称为aaa；</span><br></pre></td></tr></table></figure>

<h3 id="1-6-复制目录"><a href="#1-6-复制目录" class="headerlink" title="1.6 复制目录"></a>1.6 复制目录</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">cp -r /aaa /bbb 		# 将/⽬录下的aaa⽬录复制到/bbb⽬录下，在/bbb⽬录下的名称为aaa</span><br><span class="line">cp -r /aaa /bbb/aaa 	# 将/⽬录下的aa⽬录复制到/bbb⽬录下，且修改名为aaa;</span><br></pre></td></tr></table></figure>

<h3 id="1-7-删除目录"><a href="#1-7-删除目录" class="headerlink" title="1.7 删除目录"></a>1.7 删除目录</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">rm -r /bbb 		# 普通删除。会询问你是否删除每⼀个⽂件</span><br><span class="line">rm -rf /bbb  	# 强制删除/⽬录下的bbb⽬录。如果bbb⽬录中的⼦⽬录均被强制删除，不会提示</span><br></pre></td></tr></table></figure>

<h2 id="二-文件操作"><a href="#二-文件操作" class="headerlink" title="二.文件操作"></a>二.文件操作</h2><h3 id="2-1-删除操作"><a href="#2-1-删除操作" class="headerlink" title="2.1 删除操作"></a>2.1 删除操作</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">rm -r a.java 	# 删除当前⽬录下的a.java⽂件（每次回询问是否删除y：同意）</span><br></pre></td></tr></table></figure>

<h3 id="2-2-强制删除"><a href="#2-2-强制删除" class="headerlink" title="2.2 强制删除"></a>2.2 强制删除</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">rm -rf a.java 	# 强制删除当前⽬录下的a.java⽂件</span><br><span class="line">rm -rf ./a* 	# 强制删除当前⽬录下以a开头的所有⽂件；</span><br><span class="line">rm -rf ./* 		# 强制删除当前⽬录下所有⽂件（慎⽤）；</span><br></pre></td></tr></table></figure>

<h3 id="2-3-创建文件"><a href="#2-3-创建文件" class="headerlink" title="2.3 创建文件"></a>2.3 创建文件</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">touch 文件名</span><br></pre></td></tr></table></figure>

<h3 id="2-4-递归删除-pyc格式的文件"><a href="#2-4-递归删除-pyc格式的文件" class="headerlink" title="2.4 递归删除.pyc格式的文件"></a>2.4 递归删除.pyc格式的文件</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">find . -name &#x27;*.pyc&#x27; -exec rm -rf &#123;&#125; \;</span><br></pre></td></tr></table></figure>

<h3 id="2-5-打印当前文件夹下指定大小的文件"><a href="#2-5-打印当前文件夹下指定大小的文件" class="headerlink" title="2.5 打印当前文件夹下指定大小的文件"></a>2.5 打印当前文件夹下指定大小的文件</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">find . -name &quot;*&quot; -size 145800c -print;</span><br></pre></td></tr></table></figure>

<h3 id="2-6-递归删除指定大小的⽂件-145800）"><a href="#2-6-递归删除指定大小的⽂件-145800）" class="headerlink" title="2.6 递归删除指定大小的⽂件(145800）"></a>2.6 递归删除指定大小的⽂件(145800）</h3><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">find . -name &quot;*&quot; -size 145800c -exec rm -rf &#123;&#125; \;</span><br></pre></td></tr></table></figure>

<h3 id="2-7-递归删除指定大小的⽂件，并打印出来"><a href="#2-7-递归删除指定大小的⽂件，并打印出来" class="headerlink" title="2.7 递归删除指定大小的⽂件，并打印出来"></a>2.7 递归删除指定大小的⽂件，并打印出来</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">find . -name &quot;*&quot; -size 145800c -print -exec rm -rf &#123;&#125; \;</span><br></pre></td></tr></table></figure>

<blockquote>
<ul>
<li>“.” 表示从当前⽬录开始递归查找</li>
<li>“ -name ‘*.exe’ “ 根据名称来查找，要查找所有以.exe结尾的⽂件夹或者⽂件</li>
<li>“ -type f “ 查找的类型为⽂件</li>
<li>“-print” 输出查找的⽂件⽬录名</li>
<li>-size 145800c 指定⽂件的⼤⼩ </li>
<li>-exec rm -rf {} ; 递归删除（前⾯查询出来的结果）</li>
</ul>
</blockquote>
<p>split命令：</p>
<p>可以将一个大文件分割成若干个小文件，又是需要将文件分割成更小的片段，比如为提高可读性，生成日志等。</p>
<blockquote>
<ul>
<li>-b：值为每⼀输出档案的⼤⼩，单位为 byte</li>
<li>-C：每⼀输出档中，单⾏的最⼤ byte 数</li>
<li>-d：使⽤数字作为后缀 </li>
<li>-l：值为每⼀输出档的⾏数⼤⼩</li>
<li>-a：指定后缀⻓度(默认为2)</li>
</ul>
</blockquote>
<p>举例：</p>
<ol>
<li>使⽤split命令将上⾯创建的date.file⽂件分割成⼤⼩为10KB的⼩⽂件</li>
</ol>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">split -b 10k date.file</span><br></pre></td></tr></table></figure>

<ol start="2">
<li>⽂件被分割成多个带有字⺟的后缀⽂件，如果想⽤数字后缀可使⽤-d参数，同时可以使⽤-a length来指定后缀的⻓度</li>
</ol>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">split -b 10k date.file -d -a 3</span><br></pre></td></tr></table></figure>

<ol start="3">
<li>为分割后的⽂件指定⽂件名的前缀</li>
</ol>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">split -b 10k date.file -d -a 3 split_file</span><br></pre></td></tr></table></figure>

<ol start="4">
<li>使⽤-l选项根据⽂件的⾏数来分割⽂件，例如把⽂件分割成每个包含10⾏的⼩⽂件：</li>
</ol>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">plit -l 10 date.file	</span><br></pre></td></tr></table></figure>

<h2 id="三-⽂件内容操作（查看⽇志，更改配置⽂件）"><a href="#三-⽂件内容操作（查看⽇志，更改配置⽂件）" class="headerlink" title="三.⽂件内容操作（查看⽇志，更改配置⽂件）"></a>三.⽂件内容操作（查看⽇志，更改配置⽂件）</h2><h3 id="3-1-修改文件内容"><a href="#3-1-修改文件内容" class="headerlink" title="3.1 修改文件内容"></a>3.1 修改文件内容</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">vim a.java	  # 进⼊⼀般模式</span><br><span class="line">i(按键)		# 进⼊插⼊模式(编辑模式)</span><br><span class="line">ESC(按键) 	# 退出</span><br><span class="line">:wq			 # 保存退出（shift+：调起输⼊框）</span><br><span class="line">:q！ 	     # 不保存退出（shift+：调起输⼊框）（内容更改）</span><br><span class="line">:q 			 # 不保存退出（shift+：调起输⼊框）（没有内容更改）</span><br></pre></td></tr></table></figure>

<h3 id="3-2-查看文件内容"><a href="#3-2-查看文件内容" class="headerlink" title="3.2 查看文件内容"></a>3.2 查看文件内容</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">cat a.java 		# 查看a.java⽂件的最后⼀⻚内容；</span><br><span class="line">more a.java 	# 从第⼀⻚开始查看a.java⽂件内容，按回⻋键⼀⾏⼀⾏进⾏查看，</span><br><span class="line"> 			    # 空格键⼀⻚⼀⻚进⾏查看，q退出；</span><br><span class="line">less a.java		# 从第⼀⻚开始查看a.java⽂件内容，按回⻋键⼀⾏⼀⾏的看，</span><br><span class="line"> 			    # 按空格键⼀⻚⼀⻚的看，⽀持使⽤PageDown和PageUp翻⻚，q退出；</span><br></pre></td></tr></table></figure>

<p>总结下more和less的区别：</p>
<blockquote>
<ol>
<li>less可以按键盘上下⽅向键显示上下内容,more不能通过上下⽅向键控制显示 </li>
<li>less不必读整个⽂件，加载速度会⽐more更快</li>
<li>less退出后shell不会留下刚显示的内容,⽽more退出后会在shell上留下刚显示的内容</li>
<li>more不能后退.</li>
</ol>
</blockquote>
<h3 id="3-3-查看前后行内容"><a href="#3-3-查看前后行内容" class="headerlink" title="3.3 查看前后行内容"></a>3.3 查看前后行内容</h3><p>实时查看文件的后几行（查询日志文件更方便）</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">tail -f a.java 		# 查看a.java⽂件的后10⾏内容；</span><br></pre></td></tr></table></figure>

<p>前后几行查看：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">head a.java 		# 查看a.java⽂件的前10⾏内容（默认是显示十行）</span><br><span class="line">tail -f a.java 		# 查看a.java⽂件的后10⾏内容（默认是显示十行）</span><br><span class="line">head -n 7 a.java 	# 查看a.java⽂件的前7⾏内容</span><br><span class="line">tail -n 7 a.java 	# 查看a.java⽂件的后7⾏内容</span><br></pre></td></tr></table></figure>

<h3 id="3-4-文件内部搜索指定内容"><a href="#3-4-文件内部搜索指定内容" class="headerlink" title="3.4 文件内部搜索指定内容"></a>3.4 文件内部搜索指定内容</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">grep under 123.txt 		# 在123.txt⽂件中搜索under字符串，⼤⼩写敏感，显示⾏；</span><br><span class="line">grep -n under 123.txt 	# 在123.txt⽂件中搜索under字符串，⼤⼩写敏感，显示⾏及⾏号</span><br><span class="line">grep -v under 123.txt 	# 在123.txt⽂件中搜索under字符串，⼤⼩写敏感，显示没搜索到的⾏</span><br><span class="line">grep -i under 123.txt 	# 在123.txt⽂件中搜索under字符串，⼤⼩写敏感，显示⾏</span><br><span class="line">grep -ni under 123.txt  # 在123.txt⽂件中搜索under字符串，⼤⼩写敏感，显示⾏及⾏号</span><br></pre></td></tr></table></figure>

<h3 id="3-5-终止操作指令"><a href="#3-5-终止操作指令" class="headerlink" title="3.5 终止操作指令"></a>3.5 终止操作指令</h3><p>Ctrl+c 和 Ctrl+z 都是中断命令，但是作⽤却不⼀样</p>
<blockquote>
<ol>
<li><p>Ctrl+C扮演类似的⻆⾊，强制中断程序的执⾏</p>
</li>
<li><p>Ctrl+Z就扮演了类似的⻆⾊，将任务中断，但是任务并没有结束，在进程中只是维持挂起的状态，⽤户可以使⽤ fg&#x2F;bg操作前台或后台的任务，fg命令重新启动前台被中断的任务，bg命令把被中断的任务放在后台执⾏</p>
</li>
</ol>
</blockquote>
<h3 id="3-6-重定向功能"><a href="#3-6-重定向功能" class="headerlink" title="3.6 重定向功能"></a>3.6 重定向功能</h3><p>可以使⽤ &gt; 或 &lt; 将命令的输出的命令重定向到test.txt⽂件中（没有则创建⼀个）。</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">echo &#x27;Hello World&#x27; &gt; /root/test.txt</span><br></pre></td></tr></table></figure>

<h2 id="四-系统⽇志位置"><a href="#四-系统⽇志位置" class="headerlink" title="四.系统⽇志位置"></a>四.系统⽇志位置</h2><p>汇总日志信息：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">cat /etc/redhat-release  # 查看操作系统版本</span><br><span class="line">/var/log/message		# 系统启动后的信息和错误⽇志，是Red Hat Linux中最常⽤的⽇志之⼀</span><br><span class="line">/var/log/message 		# 系统启动后的信息和错误⽇志，是Red Hat Linux中最常⽤的⽇志之⼀</span><br><span class="line">/var/log/secure 		# 与安全相关的⽇志信息</span><br><span class="line">/var/log/maillog		# 与邮件相关的⽇志信息</span><br><span class="line">/var/log/cron			# 与定时任务相关的⽇志信息</span><br><span class="line">/var/log/spooler 		# 与UUCP和news设备相关的⽇志信息</span><br><span class="line">/var/log/boot.log 		# 守护进程启动和停⽌相关的⽇志消息</span><br></pre></td></tr></table></figure>

<p>查看某⽂件下的⽤户操作⽇志，到达操作的⽬录下，执⾏下⾯的程序：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">cat .bash_history</span><br></pre></td></tr></table></figure>

<h2 id="五-创建与删除软连接"><a href="#五-创建与删除软连接" class="headerlink" title="五.创建与删除软连接"></a>五.创建与删除软连接</h2><h3 id="5-1-建立软连接"><a href="#5-1-建立软连接" class="headerlink" title="5.1 建立软连接"></a>5.1 建立软连接</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">ln -s /usr/local/app /data</span><br></pre></td></tr></table></figure>

<blockquote>
<p> 注意：创建软连接时，data⽬录后不加 &#x2F; (加上后是查找其下⼀级⽬录)；</p>
</blockquote>
<h3 id="5-2-删除软连接"><a href="#5-2-删除软连接" class="headerlink" title="5.2 删除软连接"></a>5.2 删除软连接</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">rm -rf /data</span><br></pre></td></tr></table></figure>

<h2 id="六-压缩与解压缩"><a href="#六-压缩与解压缩" class="headerlink" title="六.压缩与解压缩"></a>六.压缩与解压缩</h2><h3 id="6-1-tar命令"><a href="#6-1-tar命令" class="headerlink" title="6.1 tar命令"></a>6.1 tar命令</h3><div style="text-align: center;">
      <img src="https://dustwind-picture-upload.oss-cn-chengdu.aliyuncs.com/img/tar%E5%91%BD%E4%BB%A4.png" alt="tar命令"/></div>

<ol>
<li>压缩（-c）</li>
</ol>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">将当前⽬录下a.java、b.java打包</span></span><br><span class="line">tar -cvf start.tar a.java b.java </span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">将当前⽬录下的所欲⽂件打包压缩成haha.tar⽂件</span></span><br><span class="line">tar -cvf start.tar ./*</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">将当前⽬录下a.java、b.java打包</span></span><br><span class="line">tar -zcvf start.tar.gz a.java b.java</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">将当前⽬录下的所欲⽂件打包压缩成start.tar.gz⽂件</span></span><br><span class="line">tar -zcvf start.tar.gz ./* </span><br></pre></td></tr></table></figure>

<ol start="2">
<li>解压缩（-x）</li>
</ol>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">解压start.tar压缩包，到当前⽂件夹下</span></span><br><span class="line">tar -xvf start.tar	</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">解压start.tar压缩包，到/usr/local⽬录下（C为⼤写，中间⽆空格）</span></span><br><span class="line">tar -xvf start.tar -C usr/local  </span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">解压start.tar.gz压缩包，到当前⽂件夹下</span></span><br><span class="line">tar -zxvf start.tar.gz</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">解压start.tar.gz压缩包，到/usr/local⽬录下（C为⼤写，中间⽆空格）</span></span><br><span class="line">tar -zxvf start.tar.gz -C usr/local </span><br></pre></td></tr></table></figure>

<ol start="3">
<li>解压缩（tar.xz文件）</li>
</ol>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">tar -xf node-v12.18.1-linux-x64.tar.xz</span><br></pre></td></tr></table></figure>

<h3 id="6-2-zip-unzip命令"><a href="#6-2-zip-unzip命令" class="headerlink" title="6.2 zip&#x2F;unzip命令"></a>6.2 zip&#x2F;unzip命令</h3><ol>
<li>压缩（zip）</li>
</ol>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">将单个⽂件压缩(lib.zip)</span></span><br><span class="line">zip lib.zip tomcat.jar</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">将lib⽬录进⾏压缩(lib.zip)</span></span><br><span class="line">zip -r lib.zip lib/ </span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">将多个⽂件压缩为zip⽂件(lib.zip)</span> </span><br><span class="line">zip -r lib.zip tomcat-embed.jar xml-aps.jar </span><br></pre></td></tr></table></figure>

<ol start="2">
<li>解压缩（unzip）</li>
</ol>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">解压⼀个zip格式压缩包</span></span><br><span class="line">unzip file1.zip</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">将`english.zip`包，解压到指定目录`/usr/app/`下</span></span><br><span class="line">unzip -d /usr/app/com.lydms.english.zip </span><br></pre></td></tr></table></figure>

<h2 id="七-Linux下文件的详细信息"><a href="#七-Linux下文件的详细信息" class="headerlink" title="七.Linux下文件的详细信息"></a>七.Linux下文件的详细信息</h2><blockquote>
<p>r:read w:write x: execute执⾏</p>
<p>解释：</p>
<ol>
<li><p>前三位代表当前⽤户对⽂件权限：可以读&#x2F;可以写&#x2F;不能执⾏</p>
</li>
<li><p>中间三位代表当前组的其他⽤户对当前⽂件的操作权限：可以读&#x2F;不能写&#x2F;不能执⾏</p>
</li>
<li><p>后三位其他⽤户对当前⽂件权限：可以读&#x2F;不能写&#x2F;不能执⾏</p>
</li>
</ol>
<p>d-rw-r–r– 1 root root 34942 Jan 19 2018 bootstrap.jar</p>
<p>备注各个部分分别为：文件类型，文件权限，链接数，所属用户，所属组，文件大小，最后修改日期，文件名</p>
</blockquote>
<h3 id="7-1-更改文件权限"><a href="#7-1-更改文件权限" class="headerlink" title="7.1 更改文件权限"></a>7.1 更改文件权限</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">chmod u+x web.xml （---x------） # 为⽂件拥有者（user）添加执⾏权限；</span><br><span class="line">chmod g+x web.xml （------x---） # 为⽂件拥有者所在组（group）添加执⾏权限；</span><br><span class="line">chmod 111 web.xml （---x--x--x） # 为所有⽤户分类，添加可执⾏权限；</span><br><span class="line">chmod 222 web.xml （--w--w--w-） # 为所有⽤户分类，添加可写⼊权限； </span><br><span class="line">chmod 444 web.xml （-r--r--r--） # 为所有⽤户分类，添加可读取权限；</span><br></pre></td></tr></table></figure>

<h2 id="八-常用的Docker容器命令"><a href="#八-常用的Docker容器命令" class="headerlink" title="八.常用的Docker容器命令"></a>八.常用的Docker容器命令</h2><h3 id="8-1-下载镜像"><a href="#8-1-下载镜像" class="headerlink" title="8.1 下载镜像"></a>8.1 下载镜像</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">格式为：wget+镜像源</span></span><br><span class="line">wget https://mirrors.huaweicloud.com/elasticsearch/7.8.0/elasticsearch-7.8.0-windows-x86_64.zip</span><br></pre></td></tr></table></figure>

<p><a target="_blank" rel="noopener" href="https://mirrors.huaweicloud.com/">华为开源镜像源</a>：<a target="_blank" rel="noopener" href="https://mirrors.huaweicloud.com/">https://mirrors.huaweicloud.com/</a></p>
<h3 id="8-2-常用命令"><a href="#8-2-常用命令" class="headerlink" title="8.2 常用命令"></a>8.2 常用命令</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">1.查看docker中下载好的镜像</span></span><br><span class="line">docker images</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">2.查询需要的容器名称</span></span><br><span class="line">docker search mysql</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">3.将需要的docker容器下载运⾏到本地(名称、端⼝号、msyql密码、ID)：</span></span><br><span class="line">docker run -di --name=first -p 3306:3306 -e MYSQL_ROOT_PASSWORD=root 26d26dsfsd31a</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">4.查看运⾏的docker容器</span></span><br><span class="line">docker ps</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">5.查看所有的docker容器（包括未运⾏的）</span></span><br><span class="line">docker ps -a</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">6.停⽌当前运⾏的docker容器</span></span><br><span class="line">docker stop first</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">7.启动docker容器</span></span><br><span class="line">docker start first</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">8.重启docker容器</span></span><br><span class="line">docker restart first</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">9.删除docker容器：</span></span><br><span class="line">docker rm first</span><br></pre></td></tr></table></figure>

<h2 id="九-运维常用命令"><a href="#九-运维常用命令" class="headerlink" title="九.运维常用命令"></a>九.运维常用命令</h2><h3 id="9-1-查询服务器状态"><a href="#9-1-查询服务器状态" class="headerlink" title="9.1 查询服务器状态"></a>9.1 查询服务器状态</h3><p>查看服务器是否可用：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">ping + IP地址</span></span><br><span class="line">ping 49.32.56.164</span><br></pre></td></tr></table></figure>

<p>查看服务器指定端口是否可用</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">telnet + IP地址</span></span><br><span class="line">telnet 49.32.56.164</span><br></pre></td></tr></table></figure>

<blockquote>
<p>Telnet安装：<a target="_blank" rel="noopener" href="https://blog.csdn.net/lydms/article/details/113698856">https://blog.csdn.net/lydms/article/details/113698856</a></p>
</blockquote>
<h3 id="9-2-常用命令"><a href="#9-2-常用命令" class="headerlink" title="9.2 常用命令"></a>9.2 常用命令</h3><ol>
<li>shutdown命令</li>
</ol>
<p>关闭计算机。shutdown是最常⽤也是最安全的关机和重启命令，它会在关机之前调⽤fsck检查磁盘，其中-h和-r是最常⽤的参数</p>
<blockquote>
<p>-h：停⽌系统服务并关机</p>
<p>-r：停⽌系统服务后重启</p>
</blockquote>
<p>举例：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">立即关机</span></span><br><span class="line">shutdown -h now</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">到10:53关机，如果该时间⼩于当前时间，则到隔天</span> </span><br><span class="line">shutdown -h 10:53</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">10分钟后⾃动关机</span></span><br><span class="line">shutdown -h +10</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">立即重启</span></span><br><span class="line">shutdown -r now</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">30分钟后重启并并发送通知给其它在线⽤户</span></span><br><span class="line">shutdown -r +30 &#x27;The System Will Reboot in 30 Mins&#x27;  </span><br></pre></td></tr></table></figure>

<ol start="2">
<li>查看处于各种连接状态数量(ESTABLISHED、CLOSE_WAIT、TIME_WAIT)</li>
</ol>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">查看处于 ESTABLISHED 状态连接</span></span><br><span class="line">netstat -nt | awk &#x27;&#123;if($NF==&quot;ESTABLISHED&quot;)&#123;wait[$5]++&#125;&#125;END&#123;for(i in wait) print i,wait[i]&#125;&#x27;</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">查看处于 CLOSE_WAIT 状态连接</span></span><br><span class="line">netstat -nt | awk &#x27;&#123;if($NF==&quot;CLOSE_WAIT&quot;)&#123;wait[$5]++&#125;&#125;END&#123;for(i in wait) print i,wait[i]&#125;&#x27;</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">查看处于 TIME_WAIT 状态连接</span></span><br><span class="line">netstat -nt | awk &#x27;&#123;if($NF==&quot;TIME_WAIT&quot;)&#123;wait[$5]++&#125;&#125;END&#123;for(i in wait) print i,wait[i]&#125;&#x27;</span><br></pre></td></tr></table></figure>

<ol start="3">
<li>ping 命令</li>
</ol>
<p>对<a target="_blank" rel="noopener" href="http://www.dustwind.club/">www.dustwind.club</a> 发送ping 包, 检查与其是否联通</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">ping -c 4 dustwind.club</span><br></pre></td></tr></table></figure>

<ol start="4">
<li>netstat命令</li>
</ol>
<p>netstat 命令⽤于显示各种⽹络相关信息，如⽹络连接, 路由表, 接⼝状态等等</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">列出所有处于监听状态的tcp端⼝</span></span><br><span class="line">netstat -lt</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">查看所有的端⼝信息, 包括 PID 和进程名称</span></span><br><span class="line">netstat -tulpn</span><br></pre></td></tr></table></figure>

<ol start="5">
<li>查看当前端⼝号占⽤情况</li>
</ol>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">1.查看某⼀端⼝的占⽤情况</span></span><br><span class="line">lsof -i:8080</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">2.显示tcp，udp的端⼝和进程等相关情况</span></span><br><span class="line">netstat -tunlp</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">3.指定端口的进程情况</span></span><br><span class="line">netstat -tunlp|grep 8080</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">4.查看PID进程情况</span></span><br><span class="line">ps -aux |grep 28990</span><br><span class="line">jstack 2246|grep &#x27;0x9eb&#x27; -A 50 	  # 根据PID，查看JVM中各线程信息(&#x27;0x9eb&#x27;为nid值）</span><br></pre></td></tr></table></figure>

<ol start="6">
<li>ps命令</li>
</ol>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">过滤得到当前系统中的 ssh 进程信息</span></span><br><span class="line">ps aux | grep &#x27;ssh&#x27;</span><br></pre></td></tr></table></figure>

<ol start="7">
<li>管道命令</li>
</ol>
<p>简单来说, Linux 中管道的作⽤是将上⼀个命令的输出作为下⼀个命令的输⼊, 像 pipe ⼀样将各个命令串联起来执行, 管道的操作符是 |</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">管道命令查看当前运⾏的程序中，名称为java的程序</span></span><br><span class="line">ps -ef|grep java</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">查看/etc/passwd⽂件中的root内容</span></span><br><span class="line">cat /etc/passwd | grep &#x27;root&#x27;</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">查看当前系统的ip连接（Windows和Linux通⽤）</span></span><br><span class="line">netstat -an</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">将sh test.sh任务放到后台，并将打印的⽇志输出到 nohup.out ⽂件中，终端不再能够接收任何输⼊（标准输⼊）</span></span><br><span class="line">nohup sh test.sh &amp;</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">将sh test.sh任务放到后台，并将打印的⽇志输出到 test.out ⽂件中，终端不再能够接收任何输⼊（标准输⼊）</span></span><br><span class="line">nohup sh test.sh &gt;&gt; test.out &amp;</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">将sh test.sh任务放到后台，并将打印的⽇志输出到nohup.out⽂件中，终端能够接收任何输⼊</span></span><br><span class="line">nohup sh test.sh &amp;</span><br></pre></td></tr></table></figure>

<ol start="8">
<li>添加Host地址</li>
</ol>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">打开配置文件</span></span><br><span class="line">vim /etc/hosts</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">在打开文件中添加内容</span></span><br><span class="line">49.32.56.164 dustwind.club</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">保存文件，重启网络</span></span><br><span class="line">/etc/init.d/network restart</span><br></pre></td></tr></table></figure>

<h2 id="十-yum常用命令"><a href="#十-yum常用命令" class="headerlink" title="十.yum常用命令"></a>十.yum常用命令</h2><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">1.下载并安装iptables</span></span><br><span class="line">yum install iptables-services</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">2.列出当前系统中安装的所有包</span></span><br><span class="line">yum list </span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">3.在rpm仓库中搜寻软件包</span></span><br><span class="line">yum search package_name</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">4.更新当前系统中所有安装的rpm包</span></span><br><span class="line">yum update package_name.rpm</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">5.更新⼀个rpm包</span></span><br><span class="line">yum update package_name</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">6.删除⼀个rpm包</span></span><br><span class="line">yum remove package_name</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">7.删除所有缓存的包和头⽂件</span></span><br><span class="line">yum clean all</span><br></pre></td></tr></table></figure>

<h2 id="十一-其他命令"><a href="#十一-其他命令" class="headerlink" title="十一.其他命令"></a>十一.其他命令</h2><ol>
<li>查看历史使用命令：</li>
</ol>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">查看历史使用命令<span class="built_in">history</span></span></span><br><span class="line">history | grep es	# 过滤与 es 相关的命令</span><br></pre></td></tr></table></figure>

<ol start="2">
<li>查看占用资源：</li>
</ol>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">ps -au 		# 占⽤的资源是从进程启动开始，计算的平均占⽤资源，⽐如cpu等</span><br><span class="line">top		    # 实时占⽤的资源</span><br></pre></td></tr></table></figure>

<ol start="3">
<li>查看当前目录所占存储：</li>
</ol>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">du -lh 						# 查看当前⽂件下各⽂件夹占⽤存储空间</span><br><span class="line">du -sh 						# 查看当前⽂件夹所占存储空间</span><br><span class="line">du --max-depth=&lt;⽬录层数&gt;      # 超过指定层数的⽬录后，予以忽略。</span><br><span class="line">du --max-depth=1 			 # 只查看当前⽬录下⽂件占⽤的存储空间</span><br></pre></td></tr></table></figure>

<ol start="4">
<li><p>管道命令：</p>
<p>根据项⽬查看进程，更加PID查看项⽬，以及项⽬路径</p>
</li>
</ol>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">ps -ef 查看所有的进程</span><br><span class="line">ps -ef | grep mysql 查看mysql相关的进程</span><br></pre></td></tr></table></figure>

<ol start="5">
<li>通过进程PID查看所占的端口号：</li>
</ol>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">netstat -nap |grep 进程ID(PID)</span><br></pre></td></tr></table></figure>

<ol start="6">
<li>查看Linux下的系统存储使用率：</li>
</ol>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">df -h 		# 查看系统硬盘使⽤情况	</span><br></pre></td></tr></table></figure>

<ol start="7">
<li>杀死进程（根据PID）：</li>
</ol>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">kill -9 2630 		# 杀死进程pid为2630的进程</span><br></pre></td></tr></table></figure>

<ol start="8">
<li>关闭防火墙：</li>
</ol>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">service iptables stop 		# 临时关闭防⽕墙</span><br><span class="line">chkconfig iptables off 		# 防⽕墙开启不启动</span><br><span class="line">service iptables status 	# 查看防⽕墙状态</span><br></pre></td></tr></table></figure>

<ol start="9">
<li>开机启动选项：<a target="_blank" rel="noopener" href="https://www.cnblogs.com/lldsn/p/10489593.html"></a></li>
</ol>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">msconfig 		# 查看开机启动选项</span><br><span class="line">chkconfig 		# 查看开机启动服务列表</span><br></pre></td></tr></table></figure>

<ol start="10">
<li>查看MySQL服务的程序状态：</li>
</ol>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">service mysql start 	# 开启MySQL </span><br><span class="line">service mysql status 	# 查看MySQL的状态 </span><br><span class="line">service mysql stop 		# 关闭MySQL </span><br></pre></td></tr></table></figure>

<h2 id="十二-Linux内核优化"><a href="#十二-Linux内核优化" class="headerlink" title="十二.Linux内核优化"></a>十二.Linux内核优化</h2><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">打开配置文件</span></span><br><span class="line">vim /etc/sysctl.conf</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">加载新的配置（需开启防⽕墙iptables，否则会报错）</span></span><br><span class="line">sysctl -p</span><br></pre></td></tr></table></figure>

<blockquote>
<p>详细查阅地址：<a target="_blank" rel="noopener" href="https://www.cnblogs.com/lldsn/p/10489593.html">https://www.cnblogs.com/lldsn/p/10489593.html</a></p>
</blockquote>
<h2 id="十三-用户权限操作"><a href="#十三-用户权限操作" class="headerlink" title="十三.用户权限操作"></a>十三.用户权限操作</h2><h3 id="13-1-用户策略"><a href="#13-1-用户策略" class="headerlink" title="13.1 用户策略"></a>13.1 用户策略</h3><ol>
<li>添加用户sum：</li>
</ol>
<blockquote>
<p>useradd –d &#x2F;usr&#x2F;sum -m sum</p>
<p>参数注释：</p>
<p>-u：指定 UID，这个 UID 必须是⼤于等于500，并没有其他⽤户占⽤的 UID</p>
<p>-g：指定默认组，可以是 GID 或者 GROUPNAME，同样也必须真实存在</p>
<p>-G：指定额外组</p>
<p>-c：指定⽤户的注释信息</p>
<p>-d： 指定⽤户的家⽬录</p>
</blockquote>
<ol start="2">
<li>已创建用户sum设置密码：</li>
</ol>
<blockquote>
<p>password sum</p>
</blockquote>
<ol start="3">
<li>为用户添加root权限（visudo命令）</li>
</ol>
<blockquote>
<p>visudo</p>
<p>步骤：</p>
<ol>
<li>在sudoers 文件中找到root用户权限位置</li>
<li>添加与root用户相同的权限（复制root行，修改root为需修改权限的用户名）</li>
</ol>
</blockquote>
<ol start="4">
<li>显示新建用户的信息</li>
</ol>
<blockquote>
<p>cat &#x2F;etc&#x2F;passwd</p>
</blockquote>
<ol start="5">
<li>删除sum用户</li>
</ol>
<blockquote>
<p>userdel sum</p>
</blockquote>
<ol start="6">
<li>删除用户文件夹</li>
</ol>
<blockquote>
<p>rm -rf &#x2F;usr&#x2F;sum</p>
</blockquote>
<ol start="7">
<li>切换到添加的用户sum</li>
</ol>
<blockquote>
<p>su sum</p>
</blockquote>
<ol start="8">
<li>回到root用户</li>
</ol>
<blockquote>
<p>exit</p>
</blockquote>
<h3 id="13-2-组策略"><a href="#13-2-组策略" class="headerlink" title="13.2 组策略"></a>13.2 组策略</h3><ol>
<li>添加用户组</li>
</ol>
<blockquote>
<p>groupadd groupname</p>
</blockquote>
<ol start="2">
<li>删除用户组</li>
</ol>
<blockquote>
<p>groupdel groupname</p>
</blockquote>
<ol start="3">
<li>显示分组信息</li>
</ol>
<blockquote>
<p>cat &#x2F;etc&#x2F;group</p>
</blockquote>
<h2 id="十四-TOP命令"><a href="#十四-TOP命令" class="headerlink" title="十四.TOP命令"></a>十四.TOP命令</h2><h3 id="14-1-top命令用于查看实时占用的资源"><a href="#14-1-top命令用于查看实时占用的资源" class="headerlink" title="14.1 top命令用于查看实时占用的资源"></a>14.1 top命令用于查看实时占用的资源</h3><blockquote>
<p>top [参数]</p>
<p>详细参数：</p>
<p>-b 	批处理</p>
<p>-c 	显示完整的治命令</p>
<p>-I 	忽略失效过程</p>
<p>-s 	保密模式</p>
<p>-S 	累积模式</p>
<p>-i&lt;时间&gt; 		设置间隔时间</p>
<p>-u&lt;用户名&gt; 	指定用户名</p>
<p>-p&lt;进程号&gt; 	指定进程</p>
<p>-n&lt;次数&gt; 		循环显示的次数</p>
</blockquote>
<h3 id="14-2-举例"><a href="#14-2-举例" class="headerlink" title="14.2 举例"></a>14.2 举例</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br></pre></td><td class="code"><pre><span class="line">top - 14:06:23 up 70 days, 16:44,  2 users,  load average: 1.25, 1.32, 1.35</span><br><span class="line">Tasks: 206 total,   1 running, 205 sleeping,   0 stopped,   0 zombie</span><br><span class="line">Cpu(s):  5.9%us,  3.4%sy,  0.0%ni, 90.4%id,  0.0%wa,  0.0%hi,  0.2%si,  0.0%st</span><br><span class="line">Mem:  32949016k total, 14411180k used, 18537836k free,   169884k buffers</span><br><span class="line">Swap: 32764556k total,        0k used, 32764556k free,  3612636k cached</span><br><span class="line"></span><br><span class="line">  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND                                               </span><br><span class="line">28894 root      22   0 1501m 405m  10m S 52.2  1.3   2534:16 java                                                                   </span><br><span class="line">18249 root      18   0 3201m 1.9g  11m S 35.9  6.0 569:39.41 java                                                                   </span><br><span class="line"> 2808 root      25   0 3333m 1.0g  11m S 24.3  3.1 526:51.85 java                                                               </span><br><span class="line">25668 root      23   0 3180m 704m  11m S 14.0  2.2 360:44.53 java                                                                   </span><br><span class="line">  574 root      25   0 3168m 611m  10m S 12.6  1.9 556:59.63 java                                                                   </span><br><span class="line"> 1599 root      20   0 3237m 1.9g  11m S 12.3  6.2 262:01.14 java                                                                   </span><br><span class="line"> 1008 root      21   0 3147m 842m  10m S  0.3  2.6   4:31.08 java                                                                   </span><br><span class="line">13823 root      23   0 3031m 2.1g  10m S  0.3  6.8 176:57.34 java                                                                   </span><br><span class="line">28218 root      15   0 12760 1168  808 R  0.3  0.0   0:01.43 top                                                                    </span><br><span class="line">29062 root      20   0 1241m 227m  10m S  0.3  0.7   2:07.32 java                                                                   </span><br><span class="line">    1 root      15   0 10368  684  572 S  0.0  0.0   1:30.85 init                                                                   </span><br><span class="line">    2 root      RT  -5     0    0    0 S  0.0  0.0   0:01.01 migration/0                                                            </span><br><span class="line">    3 root      34  19     0    0    0 S  0.0  0.0   0:00.00 ksoftirqd/0                                                            </span><br><span class="line">    4 root      RT  -5     0    0    0 S  0.0  0.0   0:00.00 watchdog/0                                                             </span><br><span class="line">    5 root      RT  -5     0    0    0 S  0.0  0.0   0:00.80 migration/1                                                            </span><br><span class="line">    6 root      34  19     0    0    0 S  0.0  0.0   0:00.00 ksoftirqd/1                                               </span><br><span class="line">    7 root      RT  -5     0    0    0 S  0.0  0.0   0:00.00 watchdog/1                                                             </span><br><span class="line">    8 root      RT  -5     0    0    0 S  0.0  0.0   0:20.59 migration/2                                                            </span><br><span class="line">    9 root      34  19     0    0    0 S  0.0  0.0   0:00.09 ksoftirqd/2                                                            </span><br><span class="line">   10 root      RT  -5     0    0    0 S  0.0  0.0   0:00.00 watchdog/2                                                             </span><br><span class="line">   11 root      RT  -5     0    0    0 S  0.0  0.0   0:23.66 migration/3                                                            </span><br><span class="line">   12 root      34  19     0    0    0 S  0.0  0.0   0:00.03 ksoftirqd/3                                                            </span><br><span class="line">   13 root      RT  -5     0    0    0 S  0.0  0.0   0:00.00 watchdog/3                                                             </span><br><span class="line">   14 root      RT  -5     0    0    0 S  0.0  0.0   0:20.29 migration/4                                                            </span><br><span class="line">   15 root      34  19     0    0    0 S  0.0  0.0   0:00.07 ksoftirqd/4                                                            </span><br><span class="line">   16 root      RT  -5     0    0    0 S  0.0  0.0   0:00.00 watchdog/4                                                             </span><br><span class="line">   17 root      RT  -5     0    0    0 S  0.0  0.0   0:23.07 migration/5                                                            </span><br><span class="line">   18 root      34  19     0    0    0 S  0.0  0.0   0:00.07 ksoftirqd/5                                                            </span><br><span class="line">   19 root      RT  -5     0    0    0 S  0.0  0.0   0:00.00 watchdog/5                                                             </span><br><span class="line">   20 root      RT  -5     0    0    0 S  0.0  0.0   0:17.16 migration/6                                                            </span><br><span class="line">   21 root      34  19     0    0    0 S  0.0  0.0   0:00.05 ksoftirqd/6                                                            </span><br><span class="line">   22 root      RT  -5     0    0    0 S  0.0  0.0   0:00.00 watchdog/6                                                             </span><br><span class="line">   23 root      RT  -5     0    0    0 S  0.0  0.0   0:58.28 migration/7</span><br></pre></td></tr></table></figure>

<p>前五行是当前系统情况整体的统计信息区，具体内容构成如下：</p>
<ol>
<li><p>第一行：任务队列信息，同 uptime 命令的执行结果。</p>
<p>具体参数说明：</p>
<p>14:06:23 — 当前系统时间</p>
<p>up 70 days, 16:44 — 系统已经运行了70天16小时44分钟（在这期间系统没有重启过的吆！）</p>
<p>2 users — 当前有2个用户登录系统</p>
<p>load average: 1.15, 1.42, 1.44 — load average后面的三个数分别是1分钟、5分钟、15分钟的负载情况。</p>
<blockquote>
<p>load average数据是每隔5秒钟检查一次活跃的进程数，然后按特定算法计算出的数值。如果这个数除以逻辑CPU的数量，结果高于5的时候就表明系统在超负荷运转了。</p>
</blockquote>
</li>
<li><p>第二行：任务总述。</p>
<p>具体参数说明：</p>
<p>Tasks — 任务（进程）</p>
<p>系统现在共有206个进程，其中处于运行中的有1个，205个在休眠（sleep），stoped状态的有0个，zombie状态（僵尸）的有0个。</p>
</li>
<li><p>第三行：cpu状态信息。</p>
<p>具体参数说明：</p>
<p>5.9%us — 用户空间占用CPU的百分比。</p>
<p>3.4% sy — 内核空间占用CPU的百分比。</p>
<p>0.0% ni — 改变过优先级的进程占用CPU的百分比</p>
<p>90.4% id — 空闲CPU百分比</p>
<p>0.0% wa — IO等待占用CPU的百分比</p>
<p>0.0% hi — 硬中断（Hardware IRQ）占用CPU的百分比</p>
<p>0.2% si — 软中断（Software Interrupts）占用CPU的百分比</p>
</li>
</ol>
<blockquote>
<p>备注：在这里CPU的使用比率和windows概念不同，需要理解linux系统用户空间和内核空间的相关知识！</p>
</blockquote>
<ol start="4">
<li><p>第四行：内存状态。</p>
<p>具体参数说明：</p>
<p>32949016k total — 物理内存总量（32GB）</p>
<p>14411180k used — 使用中的内存总量（14GB）</p>
<p>18537836k free — 空闲内存总量（18GB）</p>
<p>169884k buffers — 缓存的内存量 （169M）</p>
</li>
<li><p>第五行，swap交换分区信息。</p>
<p>具体参数说明：</p>
<p>32764556k total — 交换区总量（32GB）</p>
<p>0k used — 使用的交换区总量（0K）</p>
<p>32764556k free — 空闲交换区总量（32GB）</p>
<p>3612636k cached — 缓冲的交换区总量（3.6GB）</p>
</li>
<li><p>第六行：空行。</p>
</li>
<li><p>第七行：各进程（任务）的状态监控。</p>
<p>具体参数说明：PID — 进程id</p>
<p>USER — 进程所有者</p>
<p>PR — 进程优先级</p>
<p>NI — nice值。负值表示高优先级，正值表示低优先级</p>
<p>VIRT — 进程使用的虚拟内存总量，单位kb。VIRT&#x3D;SWAP+RES</p>
<p>RES — 进程使用的、未被换出的物理内存大小，单位kb。RES&#x3D;CODE+DATA</p>
<p>SHR — 共享内存大小，单位kb</p>
<p>S — 进程状态。D&#x3D;不可中断的睡眠状态 R&#x3D;运行 S&#x3D;睡眠 T&#x3D;跟踪&#x2F;停止 Z&#x3D;僵尸进程</p>
<p>%CPU — 上次更新到现在的CPU时间占用百分比</p>
<p>%MEM — 进程使用的物理内存百分比</p>
<p>TIME+ — 进程使用的CPU时间总计，单位1&#x2F;100秒</p>
<p>COMMAND — 进程名称（命令名&#x2F;命令行）</p>
</li>
</ol>
<h2 id="十五-文件安装"><a href="#十五-文件安装" class="headerlink" title="十五.文件安装"></a>十五.文件安装</h2><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">下载文件（file.name）：</span></span><br><span class="line">yum install -y file.name</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">上传文件：</span></span><br><span class="line">rz</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">保存文件：</span></span><br><span class="line">sz</span><br></pre></td></tr></table></figure>




      

      
    </div>
    <div class="article-info article-info-index">
      
      
	<div class="article-tag tagcloud">
		<i class="icon-price-tags icon"></i>
		<ul class="article-tag-list">
			 
        		<li class="article-tag-list-item">
        			<a href="javascript:void(0)" class="js-tag article-tag-list-link color1">Linux</a>
        		</li>
      		
		</ul>
	</div>

      

      
        <p class="article-more-link">
          <a class="article-more-a" href="/2022/07/29/%E5%B8%B8%E7%94%A8Linux%E5%91%BD%E4%BB%A4/">展开全文 >></a>
        </p>
      

      
      <div class="clearfix"></div>
    </div>
  </div>
</article>

<aside class="wrap-side-operation">
    <div class="mod-side-operation">
        
        <div class="jump-container" id="js-jump-container" style="display:none;">
            <a href="javascript:void(0)" class="mod-side-operation__jump-to-top">
                <i class="icon-font icon-back"></i>
            </a>
            <div id="js-jump-plan-container" class="jump-plan-container" style="top: -11px;">
                <i class="icon-font icon-plane jump-plane"></i>
            </div>
        </div>
        
        
    </div>
</aside>




  
    <article id="post-Git学习" class="article article-type-post  article-index" itemscope itemprop="blogPost">
  <div class="article-inner">
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/2022/06/27/Git%E5%AD%A6%E4%B9%A0/">Git学习</a>
    </h1>
  

        
        <a href="/2022/06/27/Git%E5%AD%A6%E4%B9%A0/" class="archive-article-date">
  	<time datetime="2022-06-27T05:46:31.000Z" itemprop="datePublished"><i class="icon-calendar icon"></i>2022-06-27</time>
</a>
        
      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <hr>
<h1 id="一-Git简介"><a href="#一-Git简介" class="headerlink" title="一.Git简介"></a>一.Git简介</h1><h2 id="1-1-Git工作机制"><a href="#1-1-Git工作机制" class="headerlink" title="1.1 Git工作机制"></a>1.1 Git工作机制</h2><p>Git包含两部分仓库，一个是本地仓库，一个是远程仓库。其基本工作机制如下图所示：</p>
<p><img src="https://dustwind-picture-upload.oss-cn-chengdu.aliyuncs.com/img/Git%E5%B7%A5%E4%BD%9C%E6%B5%81%E7%A8%8B.png" alt="Git工作机制"></p>
<hr>
<h1 id="二-本地仓库"><a href="#二-本地仓库" class="headerlink" title="二.本地仓库"></a>二.本地仓库</h1><p>本地仓库的操作包含分支内操作以及分支间操作。</p>
<h2 id="2-1-Git分支内操作常用命令"><a href="#2-1-Git分支内操作常用命令" class="headerlink" title="2.1 Git分支内操作常用命令"></a>2.1 Git分支内操作常用命令</h2><table>
<thead>
<tr>
<th align="center">命令名称</th>
<th align="center">作用</th>
</tr>
</thead>
<tbody><tr>
<td align="center">git config –global user.name “用户名”</td>
<td align="center">设置用户签名（用户名）</td>
</tr>
<tr>
<td align="center">git config –global user.email “邮箱号”</td>
<td align="center">设置用户签名（邮箱名）</td>
</tr>
<tr>
<td align="center">git init</td>
<td align="center">初始化本地库</td>
</tr>
<tr>
<td align="center">git status</td>
<td align="center">查看本地库状态</td>
</tr>
<tr>
<td align="center">git add 文件名</td>
<td align="center">添加到暂存区</td>
</tr>
<tr>
<td align="center">git commit -m “日志信息” 文件名</td>
<td align="center">提交到本地库</td>
</tr>
<tr>
<td align="center">git reflog</td>
<td align="center">查看版本信息</td>
</tr>
<tr>
<td align="center">git log</td>
<td align="center">查看版本详细信息</td>
</tr>
<tr>
<td align="center">get reset –hard 版本号</td>
<td align="center">回退到指定版本</td>
</tr>
</tbody></table>
<h2 id="2-2-Git分支间操作常用命令"><a href="#2-2-Git分支间操作常用命令" class="headerlink" title="2.2 Git分支间操作常用命令"></a>2.2 Git分支间操作常用命令</h2><table>
<thead>
<tr>
<th align="center">操作名称</th>
<th align="center">作用</th>
</tr>
</thead>
<tbody><tr>
<td align="center">git branch 分支名</td>
<td align="center">创建分支</td>
</tr>
<tr>
<td align="center">git branch -v</td>
<td align="center">查看分支</td>
</tr>
<tr>
<td align="center">git checkout 分支名</td>
<td align="center">切换分支</td>
</tr>
<tr>
<td align="center">git merge 分支名</td>
<td align="center">将指定分支合并到当前分支上</td>
</tr>
<tr>
<td align="center">git branch -D 分支名</td>
<td align="center">明确要删除指定分支</td>
</tr>
</tbody></table>
<h2 id="2-3-什么是分支"><a href="#2-3-什么是分支" class="headerlink" title="2.3 什么是分支"></a>2.3 什么是分支</h2><ol>
<li>在版本控制过程中，同时推进多个任务，为每个任务，我们就可以创建每个任务的单独分支；</li>
<li>使用分支意味着程序员可以把自己的工作从开发主线上分离开来，开发自己分支的时候，不会影响主线分支的运行；</li>
<li>对于初学者而言，分支可以简单理解为副本，一个分支就是一个单独的副本。</li>
</ol>
<h2 id="2-4-分支的好处"><a href="#2-4-分支的好处" class="headerlink" title="2.4 分支的好处"></a>2.4 分支的好处</h2><ol>
<li>同时并行推进多个功能开发，提高开发效率；</li>
<li>各个分支在开发过程中，如果某一个分支开发失败，不会对其他分支有任何影响。失败的分支删除重新开始即可。</li>
</ol>
<hr>
<h1 id="三-远程仓库"><a href="#三-远程仓库" class="headerlink" title="三.远程仓库"></a>三.远程仓库</h1><p>常用的远程仓库包括GitHub和Gitee。</p>
<h2 id="3-1-远程仓库的创建"><a href="#3-1-远程仓库的创建" class="headerlink" title="3.1 远程仓库的创建"></a>3.1 远程仓库的创建</h2><ol>
<li>GitHub仓库的创建</li>
</ol>
<p><img src="https://dustwind-picture-upload.oss-cn-chengdu.aliyuncs.com/img/GitHub%E5%88%9B%E5%BB%BA%E4%BD%A0%E6%96%B0%E4%BB%93%E5%BA%93.png" alt="GitHub创建新仓库"></p>
<p><img src="https://dustwind-picture-upload.oss-cn-chengdu.aliyuncs.com/img/GitHub%E4%BB%93%E5%BA%93%E5%88%9B%E5%BB%BA%E6%88%90%E5%8A%9F.png" alt="GitHub创建仓库成功"></p>
<ol start="2">
<li>Gitee仓库的创建</li>
</ol>
<p><img src="https://dustwind-picture-upload.oss-cn-chengdu.aliyuncs.com/img/Gitee%E5%88%9B%E5%BB%BA%E6%96%B0%E4%BB%93%E5%BA%93.png" alt="Gitee创建仓库"></p>
<p><img src="https://dustwind-picture-upload.oss-cn-chengdu.aliyuncs.com/img/Gitee%E4%BB%93%E5%BA%93%E5%88%9B%E5%BB%BA%E6%88%90%E5%8A%9F.png" alt="Gitee创建仓库成功"></p>
<h2 id="3-2-远程仓库的操作常用命令"><a href="#3-2-远程仓库的操作常用命令" class="headerlink" title="3.2 远程仓库的操作常用命令"></a>3.2 远程仓库的操作常用命令</h2><table>
<thead>
<tr>
<th align="center">命令名称</th>
<th align="center">作用</th>
</tr>
</thead>
<tbody><tr>
<td align="center">git remote -v</td>
<td align="center">查看当前所有远程仓库地址别名</td>
</tr>
<tr>
<td align="center">git remote add 别名 远程地址</td>
<td align="center">给远程仓库地址起别名</td>
</tr>
<tr>
<td align="center">git push 别名 分支</td>
<td align="center">推送本地仓库的分支内容到远程仓库</td>
</tr>
<tr>
<td align="center">git clone 远程地址</td>
<td align="center">从远程仓库克隆内容到本地</td>
</tr>
<tr>
<td align="center">git pull 远程库</td>
<td align="center">将远程仓库对于分支的最新内容拉下来后与当前本地分支直接合并</td>
</tr>
<tr>
<td align="center">git diff</td>
<td align="center">对比两个版本的差异</td>
</tr>
<tr>
<td align="center">git fetch</td>
<td align="center">更新远程仓库所包含分支的最新commit-id并记录到.git&#x2F;FETCH_HEAD文件</td>
</tr>
</tbody></table>
<blockquote>
<p><strong>git diff具体说明</strong>：</p>
<ul>
<li>本地工作区和暂存区的diff信息：git diff 或者 git diff file</li>
<li>暂存区和版本库的diff信息（使用git add 将工作区修改保存到了暂存区后）：git diff –cached</li>
<li>版本库中不同commit、分支的diff信息（使用git commit 将暂存区修改提交到了版本库）：git diff commit1 commit2 或 git diff branch1 branch2</li>
</ul>
</blockquote>
<hr>
<h1 id="四-Git团队协作机制"><a href="#四-Git团队协作机制" class="headerlink" title="四.Git团队协作机制"></a>四.Git团队协作机制</h1><h2 id="4-1-团队内协作"><a href="#4-1-团队内协作" class="headerlink" title="4.1 团队内协作"></a>4.1 团队内协作</h2><h2 id="4-2-团队间协作"><a href="#4-2-团队间协作" class="headerlink" title="4.2 团队间协作"></a>4.2 团队间协作</h2><h1 id="五-Git命令汇总"><a href="#五-Git命令汇总" class="headerlink" title="五.Git命令汇总"></a>五.Git命令汇总</h1><h2 id="5-1-分支内操作命令"><a href="#5-1-分支内操作命令" class="headerlink" title="5.1 分支内操作命令"></a>5.1 分支内操作命令</h2><table>
<thead>
<tr>
<th align="center">命令名称</th>
<th align="center">作用</th>
</tr>
</thead>
<tbody><tr>
<td align="center">git config –global user.name “用户名”</td>
<td align="center">设置用户签名（用户名）</td>
</tr>
<tr>
<td align="center">git config –global user.email 邮箱号</td>
<td align="center">设置用户签名（邮箱名）</td>
</tr>
<tr>
<td align="center">git init</td>
<td align="center">初始化本地库</td>
</tr>
<tr>
<td align="center">git status</td>
<td align="center">查看本地库状态</td>
</tr>
<tr>
<td align="center">git add 文件名</td>
<td align="center">添加到暂存区</td>
</tr>
<tr>
<td align="center">git commit -m “日志信息” 文件名</td>
<td align="center">提交到本地库</td>
</tr>
<tr>
<td align="center">git reflog</td>
<td align="center">查看版本信息</td>
</tr>
<tr>
<td align="center">git log</td>
<td align="center">查看版本详细信息</td>
</tr>
<tr>
<td align="center">get reset –hard 版本号</td>
<td align="center">回退版本</td>
</tr>
</tbody></table>
<h2 id="5-2-分支间操作命令"><a href="#5-2-分支间操作命令" class="headerlink" title="5.2 分支间操作命令"></a>5.2 分支间操作命令</h2><table>
<thead>
<tr>
<th align="center">命令名称</th>
<th align="center">作用</th>
</tr>
</thead>
<tbody><tr>
<td align="center">git branch {-v}</td>
<td align="center">查看本地分支</td>
</tr>
<tr>
<td align="center">git branch -r</td>
<td align="center">查看远程分支</td>
</tr>
<tr>
<td align="center">git branch [name]</td>
<td align="center">创建本地分支（新分支创建后不会自动切换为当前分支）</td>
</tr>
<tr>
<td align="center">git checkout [name]</td>
<td align="center">切换本地分支</td>
</tr>
<tr>
<td align="center">git checkout -b [name]</td>
<td align="center">创建新分支并立即切换到新分支</td>
</tr>
<tr>
<td align="center">git branch -d [name]</td>
<td align="center">删除本地分支</td>
</tr>
<tr>
<td align="center">git branch -D [name]</td>
<td align="center">删除本地分支（强制删除）</td>
</tr>
<tr>
<td align="center">git merge [name]</td>
<td align="center">将名为name的分支合并到当前分支</td>
</tr>
<tr>
<td align="center">git push origin [name]</td>
<td align="center">创建远程分支（本地分支推送到远程仓库）</td>
</tr>
<tr>
<td align="center">git push origin :heads&#x2F;[name]</td>
<td align="center">删除远程分支</td>
</tr>
<tr>
<td align="center">git push [remoteName] –delete [name]</td>
<td align="center">删除远程分支</td>
</tr>
<tr>
<td align="center">git branch -m [oldName] [newName]</td>
<td align="center">分支重命名</td>
</tr>
</tbody></table>
<h2 id="5-3-远程仓库操作命令"><a href="#5-3-远程仓库操作命令" class="headerlink" title="5.3 远程仓库操作命令"></a>5.3 远程仓库操作命令</h2><table>
<thead>
<tr>
<th align="center">命令名称</th>
<th align="center">作用</th>
</tr>
</thead>
<tbody><tr>
<td align="center">git <strong>clone</strong> [address]</td>
<td align="center">从远程仓库克隆到本地</td>
</tr>
<tr>
<td align="center">git <strong>remote</strong> -v</td>
<td align="center">查看远程仓库</td>
</tr>
<tr>
<td align="center">git remote add [name] [url]</td>
<td align="center">添加远程仓库并给其取别名</td>
</tr>
<tr>
<td align="center">git remote rm [name]</td>
<td align="center">删除远程仓库</td>
</tr>
<tr>
<td align="center">git remote set-url –push[name]</td>
<td align="center">修改远程仓库</td>
</tr>
<tr>
<td align="center">git <strong>pull</strong> [remoteName] [localBranchName]</td>
<td align="center">拉取远程仓库</td>
</tr>
<tr>
<td align="center">git <strong>push</strong> [remoteName] [localBranchName]</td>
<td align="center">推送本地仓库的分支内容到远程仓库</td>
</tr>
</tbody></table>
<h2 id="5-4-版本操作命令（很少使用）"><a href="#5-4-版本操作命令（很少使用）" class="headerlink" title="5.4 版本操作命令（很少使用）"></a>5.4 版本操作命令（很少使用）</h2><table>
<thead>
<tr>
<th align="center">命令名称</th>
<th align="center">作用</th>
</tr>
</thead>
<tbody><tr>
<td align="center">git tag</td>
<td align="center">查看版本</td>
</tr>
<tr>
<td align="center">git tag [name]</td>
<td align="center">创建版本</td>
</tr>
<tr>
<td align="center">git tag -d [name]</td>
<td align="center">删除版本</td>
</tr>
<tr>
<td align="center">git tag -r</td>
<td align="center">查看远程版本</td>
</tr>
<tr>
<td align="center">git push [remoteName] [localBranchName]</td>
<td align="center">创建远程版本</td>
</tr>
<tr>
<td align="center">git push origin :refs&#x2F;tags&#x2F;[name]</td>
<td align="center">删除远程版本</td>
</tr>
</tbody></table>
<h2 id="5-5-子模块操作命令"><a href="#5-5-子模块操作命令" class="headerlink" title="5.5 子模块操作命令"></a>5.5 子模块操作命令</h2><table>
<thead>
<tr>
<th align="center">命令名称</th>
<th align="center">作用</th>
</tr>
</thead>
<tbody><tr>
<td align="center">git submodule add [url] [path]</td>
<td align="center">添加子模块</td>
</tr>
<tr>
<td align="center"><strong>git</strong> submodule init</td>
<td align="center">初始化子模块（只需首次检出仓库时运行一下）</td>
</tr>
<tr>
<td align="center"><strong>git</strong> submodule update</td>
<td align="center">更新子模块（每次更新或切换分支后都需要运行一下）</td>
</tr>
</tbody></table>
<p>PS:删除子模块的步骤：</p>
<ul>
<li><p>git rm –cached [path]</p>
</li>
<li><p>编辑 “.gitmodules” 文件，将子模块的相关配置节点删除掉</p>
</li>
<li><p>编辑 “. <strong>git</strong>&#x2F;config” 文件，将子模块的相关配置节点删除掉</p>
</li>
<li><p>手动删除子模块残留的目录</p>
</li>
</ul>
<h2 id="5-6-Git忽略文件、文件夹不提交"><a href="#5-6-Git忽略文件、文件夹不提交" class="headerlink" title="5.6 Git忽略文件、文件夹不提交"></a>5.6 Git忽略文件、文件夹不提交</h2><p>在仓库根目录下创建名称为“.gitignore”的文件，写入不需要的文件夹名或文件，每个元素占一行即可，如:</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># See https://help.github.com/articles/ignoring-files/ for more about ignoring</span></span><br><span class="line"><span class="comment"># dependencies</span></span><br><span class="line">/node_modules</span><br><span class="line"><span class="comment"># production</span></span><br><span class="line">/dist</span><br><span class="line"><span class="comment"># misc</span></span><br><span class="line">.DS_Store</span><br><span class="line">npm-debug.log*</span><br><span class="line">.idea</span><br></pre></td></tr></table></figure>

<h2 id="5-7-其他操作命令"><a href="#5-7-其他操作命令" class="headerlink" title="5.7 其他操作命令"></a>5.7 其他操作命令</h2><table>
<thead>
<tr>
<th align="center">命令名称</th>
<th align="center">作用</th>
</tr>
</thead>
<tbody><tr>
<td align="center">git reset –hard [version]</td>
<td align="center">回退到指定版本</td>
</tr>
<tr>
<td align="center">git clone -b [branchName] [address]</td>
<td align="center">拉取指定分支代码</td>
</tr>
<tr>
<td align="center">git push –set-upstream origin test</td>
<td align="center">服务上未创建分支时提交代码</td>
</tr>
</tbody></table>

      

      
    </div>
    <div class="article-info article-info-index">
      
      
	<div class="article-tag tagcloud">
		<i class="icon-price-tags icon"></i>
		<ul class="article-tag-list">
			 
        		<li class="article-tag-list-item">
        			<a href="javascript:void(0)" class="js-tag article-tag-list-link color4">Git</a>
        		</li>
      		
		</ul>
	</div>

      

      
        <p class="article-more-link">
          <a class="article-more-a" href="/2022/06/27/Git%E5%AD%A6%E4%B9%A0/">展开全文 >></a>
        </p>
      

      
      <div class="clearfix"></div>
    </div>
  </div>
</article>

<aside class="wrap-side-operation">
    <div class="mod-side-operation">
        
        <div class="jump-container" id="js-jump-container" style="display:none;">
            <a href="javascript:void(0)" class="mod-side-operation__jump-to-top">
                <i class="icon-font icon-back"></i>
            </a>
            <div id="js-jump-plan-container" class="jump-plan-container" style="top: -11px;">
                <i class="icon-font icon-plane jump-plane"></i>
            </div>
        </div>
        
        
    </div>
</aside>




  
    <article id="post-STL标准模版类" class="article article-type-post  article-index" itemscope itemprop="blogPost">
  <div class="article-inner">
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/2022/06/25/STL%E6%A0%87%E5%87%86%E6%A8%A1%E7%89%88%E7%B1%BB/">STL标准模板库</a>
    </h1>
  

        
        <a href="/2022/06/25/STL%E6%A0%87%E5%87%86%E6%A8%A1%E7%89%88%E7%B1%BB/" class="archive-article-date">
  	<time datetime="2022-06-25T02:19:39.000Z" itemprop="datePublished"><i class="icon-calendar icon"></i>2022-06-25</time>
</a>
        
      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <h1 id="一-STL的六大组件"><a href="#一-STL的六大组件" class="headerlink" title="一.STL的六大组件"></a>一.STL的六大组件</h1><p>STL（Standard Template Library，标准模板库）是为了建立数据结构和算法的一套标准，并且降低它们之间的耦合关系，以提升各自的独立性、弹性、交互操作性。STL包含容器、算法、迭代器、仿函数、适配器（配接器）、空间配置器六大组件。</p>
<blockquote>
<p>STL的优点：</p>
<ol>
<li>被内建在编译器内部，无需额外安装。</li>
<li>将数据和操作分离。数据由容器类别加以管理，操作则由可定制的算法定义。迭代器在两者之间充当连接的桥梁，以使算法可以和容器交互运作。</li>
<li>高可重用性，高性能，高移植性，跨平台的优点</li>
</ol>
</blockquote>
<hr>
<h2 id="1-1-容器"><a href="#1-1-容器" class="headerlink" title="1.1 容器"></a>1.1 容器</h2><p>容器（Containers）存放的是各种数据结构，如vector、list、deque等；而从<strong>实现角度</strong>讲，STL容器就是一种 class template。</p>
<p>根据数据在容器中的排列特性，容器可分为序列式容器和关联式容器：</p>
<ul>
<li>序列式容器：强调值的排序，序列式容器中的每个元素均有固定位置，除非用插入或删除操作改变这个位置。</li>
<li>关联式容器：是非线性的树结构，更准确的说是二叉树结构。各元素之间没有严格的物理上的顺序关系，元素在容器中并没有保存元素置入容器时的逻辑顺序。关联式容器的显著特点：它是以键值的方式来保存数据。</li>
</ul>
<p>此外还有容器适配器：适配器是使一事物的行为类似于另一事物的行为的一种机制。容器适配器是让一种已存在的容器类型采用另一种不同的抽象类型的工作方式来实现的一种机制。</p>
<hr>
<h2 id="1-2-算法"><a href="#1-2-算法" class="headerlink" title="1.2 算法"></a>1.2 算法</h2><p>算法（Algorithms）是什么，<strong>算法就是步骤</strong>。算法就是解决特定逻辑问题及数学问题的有限步骤的合集。</p>
<p>算法具有<strong>五大基本特性</strong>：输入输出、有穷性、确定性、可行性。</p>
<p>STL 收录的算法是经过了无数程序人在实践中证明极具复用价值的合集。算法大致可以分为：</p>
<ul>
<li>质变算法：运算中会更改区间内元素的内容。如拷贝，替换，删除等。</li>
<li>非质变算法：运算中不会更改区间内的元素内容。如查找、计数、遍历等。</li>
</ul>
<hr>
<h2 id="1-3-迭代器"><a href="#1-3-迭代器" class="headerlink" title="1.3 迭代器"></a>1.3 迭代器</h2><p>迭代器（Iterators）是一种抽象的设计概念，现实程序语言中并没有直接对应于这个概念的实物。</p>
<p>《Design Patterns》中 iterator 模式定义如下：提供一种方法，使之能够依序寻访某个容器所含的各个元素，而又无需暴露该容器的内部表示方式。</p>
<p>迭代器的分类：</p>
<table>
<thead>
<tr>
<th align="center">迭代器</th>
<th align="center">功能</th>
<th align="center">描述</th>
</tr>
</thead>
<tbody><tr>
<td align="center">输入迭代器</td>
<td align="center">提供数据的只读访问</td>
<td align="center">只读</td>
</tr>
<tr>
<td align="center">输出迭代器</td>
<td align="center">提供数据的只写访问</td>
<td align="center">只写</td>
</tr>
<tr>
<td align="center">前向迭代器</td>
<td align="center">提供数据的读写操作并能向前推进推进操作</td>
<td align="center">读写</td>
</tr>
<tr>
<td align="center">双向迭代器</td>
<td align="center">提供数据的读写操作并能向前和向后推进操作</td>
<td align="center">读写</td>
</tr>
<tr>
<td align="center">随机访问迭代器</td>
<td align="center">提供数据的读写操作并能随机跳跃访问容器任意位置数据</td>
<td align="center">读写</td>
</tr>
</tbody></table>
<hr>
<h2 id="1-4-仿函数"><a href="#1-4-仿函数" class="headerlink" title="1.4 仿函数"></a>1.4 仿函数</h2><p>仿函数（Functors）是行为类似函数，可作为算法的某种策略。从实现角度来看，仿函数是一种重载了 operator() 的 class 或者class template</p>
<hr>
<h2 id="1-5-适配器（配接器）"><a href="#1-5-适配器（配接器）" class="headerlink" title="1.5 适配器（配接器）"></a>1.5 适配器（配接器）</h2><p>适配器（Adapters）是使一事物的行为类似于另一事物的行为的一种机制。容器适配器是让一种已存在的容器类型采用另一种不同的抽象类型的工作方式来实现的一种机制。它实质还是一个容器，只是它不依赖于具体的标准容器类型，可以理解为容器的模版；或者理解为容器的接口，适配器具体采用哪种容器类型去实现，在定义适配器的时候决定。</p>
<hr>
<h2 id="1-6-配置器"><a href="#1-6-配置器" class="headerlink" title="1.6 配置器"></a>1.6 配置器</h2><p>配置器（Allocators）是负责空间的配置与管理。从实现角度看配置器是一个实现了动态空间配置、空间管理、空间释放的class tempalte。</p>
<blockquote>
<p>STL六大组件关系交错：</p>
<p>容器通过空间配置器取得数据存储空间，算法通过迭代器存储容器中的内容，仿函数可以协助算法完成不同的策略的变化，而适配器可以修饰仿函数。</p>
</blockquote>
<hr>
<h1 id="二-STL常用容器类"><a href="#二-STL常用容器类" class="headerlink" title="二.STL常用容器类"></a>二.STL常用容器类</h1><p>STL常用容器类包括如下：</p>
<p> string、vector、deque、list、forward_list、stack、queue、priority_queue、map、multimap、set、multiset、unordered_map 、unordered_multimap、unordered_set、unordered_multiset。</p>
<p>标准容器类的分类及其特点：</p>
<ol>
<li>顺序式容器</li>
</ol>
<table>
<thead>
<tr>
<th align="center">名称</th>
<th align="center">特点</th>
</tr>
</thead>
<tbody><tr>
<td align="center">array</td>
<td align="center">大小是固定的，无法动态的扩展或收缩</td>
</tr>
<tr>
<td align="center">vector</td>
<td align="center">从后面快速插入与删除元素，可直接访问任何元素</td>
</tr>
<tr>
<td align="center">deque</td>
<td align="center">从前面或者后面插入与删除元素，可直接访问任何元素</td>
</tr>
<tr>
<td align="center">list</td>
<td align="center">双向链表，可从任意地方快速插入与删除</td>
</tr>
<tr>
<td align="center">forward_list</td>
<td align="center">单链表，可从任意地方快速插入与删除</td>
</tr>
</tbody></table>
<ol start="2">
<li>容器适配器</li>
</ol>
<table>
<thead>
<tr>
<th align="center">名称</th>
<th align="center">特点</th>
</tr>
</thead>
<tbody><tr>
<td align="center">stack</td>
<td align="center">后进先出（LIFO）</td>
</tr>
<tr>
<td align="center">queue</td>
<td align="center">先进先出（FIFO）</td>
</tr>
<tr>
<td align="center">priority_queue</td>
<td align="center">最高优先级总是第一个出列</td>
</tr>
</tbody></table>
<ol start="3">
<li>关联式容器</li>
</ol>
<table>
<thead>
<tr>
<th align="center">名称</th>
<th align="center">特点</th>
</tr>
</thead>
<tbody><tr>
<td align="center">map</td>
<td align="center">一对多映射，基于关键字快速查找，不允许重复值</td>
</tr>
<tr>
<td align="center">multimap</td>
<td align="center">一对多映射，基于关键字快速查找，允许重复值</td>
</tr>
<tr>
<td align="center">set</td>
<td align="center">快速查找，不允许重复值</td>
</tr>
<tr>
<td align="center">multiset</td>
<td align="center">快速查找，允许重复值</td>
</tr>
</tbody></table>
<ol start="4">
<li>无序关联式容器</li>
</ol>
<table>
<thead>
<tr>
<th align="center">名称</th>
<th align="center">特点</th>
</tr>
</thead>
<tbody><tr>
<td align="center">unordered_map</td>
<td align="center">无序</td>
</tr>
<tr>
<td align="center">unordered_multimap</td>
<td align="center">无序</td>
</tr>
<tr>
<td align="center">unordered_set</td>
<td align="center">无序</td>
</tr>
<tr>
<td align="center">unordered_multiset</td>
<td align="center">无序</td>
</tr>
</tbody></table>
<hr>
<h2 id="2-1-string-类"><a href="#2-1-string-类" class="headerlink" title="2.1 string 类"></a>2.1 string 类</h2><p>string  是 C++ 标准库中一个重要的容器，实际上它是一个类，而不是一个容器模板。</p>
<p>C语言字符串（以空字符结尾的字符数组）太过复杂难于掌握，不适合大程序的开发，所以C++标准库定义了一种 string 类，定义在 <string> 头文件当中。string 类是 STL 中 对 basic_string 模板实例化得到的模板类。其定义如下：</p>
<figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">typedef</span> basic_string string;</span><br></pre></td></tr></table></figure>

<hr>
<h2 id="2-2-array-容器"><a href="#2-2-array-容器" class="headerlink" title="2.2 array 容器"></a>2.2 array 容器</h2><p>是 C++ 11 标准中新增的顺序容器，它就是在 C++ 普通数组的基础上，添加了成员函数和全局函数。</p>
<p>它使用比普通数组更安全，且效率相当。array 容器的大小是固定的，无法动态的扩展或收缩，因此它只允许访问或者替换存储的数据元素。</p>
<hr>
<h2 id="2-3-vector-容器"><a href="#2-3-vector-容器" class="headerlink" title="2.3 vector 容器"></a>2.3 vector 容器</h2><p>vector 称为向量容器，是一种线性顺序结构。相当于数组，但其大小可以不预先指定，并且自动扩展。它可以像数组一样被操作，由于它的特性我们完全可以将 vector 看作动态数组。</p>
<p>在创建一个vector 后，它会自动在内存中分配一块连续的内存空间进行数据存储，初始的空间大小可以预先指定也可以由vector 默认指定，这个大小由 capacity() 函数的返回值确定。当存储的数据超过分配的空间时 vector 会重新分配一块内存块，但这样的分配是很耗时的，在重新分配空间时它会做这样的动作：</p>
<ol>
<li><p>首先，vector 申请一块更大的内存块；</p>
</li>
<li><p>其次，将原来的数据拷贝到新的内存块中；</p>
</li>
<li><p>然后，销毁掉原内存块中的对象（调用对象的析构函数）；</p>
</li>
<li><p>最后，将原来的内存空间释放掉。</p>
</li>
</ol>
<blockquote>
<p>注：vector 容器更擅长在尾部插入或删除元素而不擅长在容器头部或者中部插入或删除元素。</p>
</blockquote>
<figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;vector&gt;</span> <span class="comment">// 头文件引用</span></span></span><br><span class="line">vector&lt;<span class="type">int</span>&gt; vec;  <span class="comment">// 创建</span></span><br><span class="line">vec.<span class="built_in">push_back</span>(x); <span class="comment">// 添加 o(1)</span></span><br><span class="line">vec.<span class="built_in">pop_back</span>();   <span class="comment">// 删除 o(1)</span></span><br><span class="line">vec[i]            <span class="comment">// 访问 o(1)</span></span><br></pre></td></tr></table></figure>

<hr>
<h2 id="2-4-deque-容器"><a href="#2-4-deque-容器" class="headerlink" title="2.4 deque 容器"></a>2.4 deque 容器</h2><p>deque 是 double-ended queue 的缩写，又称双端队列。</p>
<p>deque 容器和 vector 容器的相同点：</p>
<ol>
<li><p>deque 容器也擅长在序列尾部添加或删除元素，而不擅长在序列中间添加或删除元素；</p>
</li>
<li><p>deque 容器也可根据需要修改自身的容量和大小。</p>
</li>
</ol>
<figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;deque&gt;</span> <span class="comment">//引用头文件</span></span></span><br><span class="line">deque&lt;<span class="type">int</span>&gt; deq;  <span class="comment">// 创建</span></span><br><span class="line"><span class="comment">// 添加 o(1)</span></span><br><span class="line">deq.<span class="built_in">push_front</span>();</span><br><span class="line">deq.<span class="built_in">push_back</span>();</span><br><span class="line"><span class="comment">// 删除 o(1)</span></span><br><span class="line">deq.<span class="built_in">pop_front</span>();</span><br><span class="line">deq.<span class="built_in">pop_back</span>();</span><br><span class="line"><span class="comment">// 访问 o(1)</span></span><br><span class="line">deq.<span class="built_in">front</span>();</span><br><span class="line">deq.<span class="built_in">back</span>();</span><br></pre></td></tr></table></figure>

<hr>
<h2 id="2-5-list-容器"><a href="#2-5-list-容器" class="headerlink" title="2.5 list 容器"></a>2.5 list 容器</h2><p>list 容器，又称双向链表容器，即该容器的底层是以双向链表的形式实现的。这意味着，list 容器中的元素可以分散存储在内存空间里，而不是必须存储在一整块连续的内存空间中。</p>
<hr>
<h2 id="2-6-forward-list-容器"><a href="#2-6-forward-list-容器" class="headerlink" title="2.6 forward_list 容器"></a>2.6 forward_list 容器</h2><p>forward_list 容器是 C++ 11 新加入的容器，其底层实现和 list 容器一样，采用的也是链表结构，但是 forward_list 使用的是<strong>单链表</strong>，而 list 使用的是<strong>双向链表</strong>。</p>
<hr>
<h2 id="2-7-stack-容器"><a href="#2-7-stack-容器" class="headerlink" title="2.7 stack 容器"></a>2.7 stack 容器</h2><p>stack 是限定仅在表尾进行插入删除操作的线性表，又称为后进先出（<strong>LIFO</strong>）的线性表。它不允许遍历，任何时候外界只能访问 stack 顶部的元素，只有在移除 stack 顶部的元素后，才能访问下方的元素。默认情况下，stack 使用 deque 作为底层容器。stack 容器应用广泛，如编辑器中的 undo （撤销操作）机制。</p>
<figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;stack&gt;</span> <span class="comment">//引用头文件</span></span></span><br><span class="line">stack&lt;<span class="type">int</span>&gt; stk;  <span class="comment">// 创建</span></span><br><span class="line">stk.<span class="built_in">push</span>(x);     <span class="comment">// 添加 o(1)</span></span><br><span class="line">stk.<span class="built_in">pop</span>();       <span class="comment">// 删除 o(1)</span></span><br><span class="line">stk.<span class="built_in">top</span>();       <span class="comment">// 访问 o(1)</span></span><br></pre></td></tr></table></figure>

<hr>
<h2 id="2-8-queue-容器"><a href="#2-8-queue-容器" class="headerlink" title="2.8 queue 容器"></a>2.8 queue 容器</h2><p>queue 是限定表的一端进行插入操作，表的另一端进行删除操作的线性表，队列又称为先进先出（<strong>FIFO</strong>）的线性表。</p>
<figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;queue&gt;</span> <span class="comment">//引用头文件</span></span></span><br><span class="line">queue&lt;<span class="type">int</span>&gt; que;  <span class="comment">// 创建</span></span><br><span class="line">que.<span class="built_in">push</span>();      <span class="comment">// 添加 o(1)</span></span><br><span class="line">que.<span class="built_in">pop</span>();       <span class="comment">// 删除 o(1)</span></span><br><span class="line">que.<span class="built_in">front</span>();     <span class="comment">// 访问 o(1)</span></span><br></pre></td></tr></table></figure>

<hr>
<h2 id="2-9-priority-queue-容器"><a href="#2-9-priority-queue-容器" class="headerlink" title="2.9 priority_queue 容器"></a>2.9 priority_queue 容器</h2><p>priority_queue 的本质是<strong>大顶堆</strong>。priority_queue 在内部维护一个基于二叉树的大顶堆数据结构，在这个数据结构中，最大的元素始终位于堆顶部，只有堆顶部的数据元素（max heap element）才能被访问获取。当然，也可以通过自定义模板参数中的 class Compare 实现一个<strong>小顶堆</strong>。相比于 queue（普通队列）的先进先出（FIFO），priority_queue 实现最高优先级先出。</p>
<figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;queue&gt;</span>       <span class="comment">//引用头文件</span></span></span><br><span class="line">priority_queue&lt;<span class="type">int</span>&gt; q; <span class="comment">// 创建</span></span><br><span class="line">q.<span class="built_in">push</span>(x);             <span class="comment">// 添加 o(logn)</span></span><br><span class="line">q.<span class="built_in">pop</span>();               <span class="comment">// 删除 o(logn)</span></span><br><span class="line">q.<span class="built_in">top</span>();               <span class="comment">// 访问 o(1)</span></span><br></pre></td></tr></table></figure>

<hr>
<h2 id="2-10-map-容器"><a href="#2-10-map-容器" class="headerlink" title="2.10 map 容器"></a>2.10 map 容器</h2><p>map 通过底层的<strong>红黑树</strong>数据结构将所有的数据元素按照 key 的相对大小进行排序，所实现的排序效果也是严格弱序特性。map 支持在一个子集合上进行直接迭代器访问，因为 map 中的元素是被有序组织的。</p>
<figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;map&gt;</span>      <span class="comment">//引用头文件</span></span></span><br><span class="line">map&lt;string, <span class="type">int</span>&gt; m; <span class="comment">// 创建</span></span><br><span class="line">m[str] = x;         <span class="comment">// 添加 o(logn)</span></span><br><span class="line">m.<span class="built_in">erase</span>(it);        <span class="comment">// 删除 o(logn)</span></span><br><span class="line"><span class="comment">// 访问 o(logn)</span></span><br><span class="line">m.<span class="built_in">count</span>(str);</span><br><span class="line">m[str];</span><br></pre></td></tr></table></figure>

<hr>
<h2 id="2-11-multimap-容器"><a href="#2-11-multimap-容器" class="headerlink" title="2.11 multimap 容器"></a>2.11 multimap 容器</h2><p>multimap 是关联式容器，是使用红黑树对记录型的元素数据,按元素键值的比较关系，进行快速的插入、删除和检索操作，所不同的是 multimap 允许将具有重复键值的元素插入容器。</p>
<p>multimap 按照特定顺序来存储键值对 &lt;key、value&gt; ，其中多个键值对之间的 key 可以重复；键 key 通常用于排序及唯一标识元素，值 value 则存储与键 key 关联的内容。</p>
<hr>
<h2 id="2-12-set-容器"><a href="#2-12-set-容器" class="headerlink" title="2.12 set 容器"></a>2.12 set 容器</h2><p>set 就是集合，是利用二叉树实现，集合中的每个元素只出现一次(参照数学中集合的互斥性)，并且是排好序的（默认按键值升序排列）。</p>
<figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;set&gt;</span> <span class="comment">//引用头文件</span></span></span><br><span class="line">set&lt;<span class="type">int</span>&gt; s;    <span class="comment">// 创建</span></span><br><span class="line">s.<span class="built_in">insert</span>(x);   <span class="comment">// 添加 o(logn)</span></span><br><span class="line">s.<span class="built_in">erase</span>(it);   <span class="comment">// 删除 o(logn)</span></span><br><span class="line">s.<span class="built_in">count</span>(x);    <span class="comment">// 访问 o(k+logn)</span></span><br></pre></td></tr></table></figure>

<hr>
<h2 id="2-13-multiset-容器"><a href="#2-13-multiset-容器" class="headerlink" title="2.13 multiset 容器"></a>2.13 multiset 容器</h2><ol>
<li>multiset 是按照特定顺序存储元素的容器，其中元素是可以重复的；</li>
<li>元素的 value 会识别它组成的键值对，multiset 元素的值不能在容器中进行修改，但可以插入和删除；</li>
<li>multiset 在内部按照特定的严格弱排序准则进行排序；</li>
<li>multiset 容器通过 key 访问单个元素比 unordered_multiset 容器慢，但当使用迭代器遍历的时候，会得到一个有序序列；</li>
<li>multiset 的底层是二叉搜索树（红黑树）。</li>
</ol>
<hr>
<h2 id="2-14-unordered-map-容器"><a href="#2-14-unordered-map-容器" class="headerlink" title="2.14 unordered_map 容器"></a>2.14 unordered_map 容器</h2><ol>
<li>unordered_map 是一个将 key 和 value 关联起来的容器，可以根据单个 key 键高效查找对应 value 值；</li>
<li>key 键是唯一的，key 键和 value 值的数据类型可以不同；</li>
<li>unordered_map 存储是无序的，是根据 key 键的哈希值将元素存储在指定位置，并且根据 key 键查找单个value 值时非常高效；</li>
<li>unordered_map 查询单个 key 键效率比 map 高，但是查询某一范围内的 key 键时比 map 效率低；</li>
<li>可以使用 [ ] 操作符来访问 key 键对应的 value 值。</li>
</ol>
<blockquote>
<p>注：如果需要内部元素自动排序，使用map，不需要排序使用unordered_map。</p>
</blockquote>
<figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;unordered_map&gt;</span>      <span class="comment">//引用头文件</span></span></span><br><span class="line">unordered_map&lt;string, <span class="type">int</span>&gt; m; <span class="comment">// 创建</span></span><br><span class="line">m[str] = x;                   <span class="comment">// 添加 o(1) / o(n)</span></span><br><span class="line">m.<span class="built_in">erase</span>(it);                  <span class="comment">// 删除 o(1) / o(n)</span></span><br><span class="line"><span class="comment">// 访问 o(1) / o(n)</span></span><br><span class="line">m.<span class="built_in">count</span>(str);</span><br><span class="line">m[str];</span><br></pre></td></tr></table></figure>

<hr>
<h2 id="2-15-unordered-multimap-容器"><a href="#2-15-unordered-multimap-容器" class="headerlink" title="2.15 unordered_multimap 容器"></a>2.15 unordered_multimap 容器</h2><p>unordered_multimap 是一个封装哈希表的无序容器。容器中每个元素都是键值对 &lt;key、value&gt; ，每个 key 键可重复出现。</p>
<hr>
<h2 id="2-16-unordered-set-容器"><a href="#2-16-unordered-set-容器" class="headerlink" title="2.16 unordered_set  容器"></a>2.16 unordered_set  容器</h2><p>unordered_set 是一种不按特定顺序存储唯一元素的容器，允许根据元素的值快速检索单个元素。unordered_set 容器和 set 容器很像，唯一的区别就在于 set 容器会自行对存储的数据进行排序，而unordered_set 容器不会。</p>
<p>几大特性：</p>
<ol>
<li>不以键值对 &lt;key、value&gt;的形式存储数据，而是直接存储数据的值；</li>
<li>容器内部存储的各个元素的值都互不相等，且不能被修改；</li>
<li>不对内部存储的数据进行排序。</li>
</ol>
<figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;unordered_set&gt;</span> <span class="comment">//引用头文件</span></span></span><br><span class="line">unordered_set&lt;<span class="type">int</span>&gt; s;    <span class="comment">// 创建</span></span><br><span class="line">s.<span class="built_in">insert</span>(x);             <span class="comment">// 添加 o(1) / o(n)</span></span><br><span class="line">s.<span class="built_in">erase</span>(it);             <span class="comment">// 删除 o(1) / o(n)</span></span><br><span class="line">s.<span class="built_in">count</span>(x);              <span class="comment">// 访问 o(1) / o(n)</span></span><br></pre></td></tr></table></figure>

<hr>
<h2 id="2-17-unordered-multiset-容器"><a href="#2-17-unordered-multiset-容器" class="headerlink" title="2.17 unordered_multiset  容器"></a>2.17 unordered_multiset  容器</h2><p>unordered_multiset 容器可同时存储多个相同值的元素，且这些元素会存储到哈希表中（本质就是链表）。</p>
<p>它有如下特性：</p>
<ul>
<li>不以键值对 &lt;key、value&gt;的形式存储数据，而是直接存储数据的值；</li>
<li>该类型容器底层采用的也是哈希表存储结构，它不会对内部存储的数据进行排序；</li>
<li>容器内部存储的元素值不能被修改。</li>
</ul>
<hr>
<h1 id="三-C-的一些函数使用"><a href="#三-C-的一些函数使用" class="headerlink" title="三.C++的一些函数使用"></a>三.C++的一些函数使用</h1><h2 id="3-1-algorithm头文件"><a href="#3-1-algorithm头文件" class="headerlink" title="3.1 algorithm头文件"></a>3.1 algorithm头文件</h2><p>algorithm 头文件是C++的标准算法库，它主要应用在容器上。此头文件常用的函数有：</p>
<ol>
<li>max()、min()、abs() 函数</li>
<li>swap() 函数</li>
<li>reverse() 函数</li>
<li>sort() 函数</li>
<li>find() 函数</li>
<li>upper_bound()、lower_bound() 函数</li>
<li>fill() 函数</li>
<li>count() 函数</li>
<li>_gcd() 函数求最大公约数</li>
<li>set_intersection()、set_union()、set_difference() 函数</li>
</ol>
<hr>
<h2 id="3-2-转换和判定函数"><a href="#3-2-转换和判定函数" class="headerlink" title="3.2 转换和判定函数"></a>3.2 转换和判定函数</h2><figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">stoi</span>(<span class="type">const</span> string *str);	<span class="comment">//</span></span><br><span class="line"><span class="built_in">atoi</span>(<span class="type">const</span> <span class="type">char</span> *ch);		<span class="comment">//	</span></span><br><span class="line"><span class="built_in">atol</span>(<span class="type">const</span> <span class="type">char</span> *str);		<span class="comment">//</span></span><br><span class="line"></span><br><span class="line"><span class="built_in">islower</span>(<span class="type">char</span> c);	<span class="comment">//是否为小写字母</span></span><br><span class="line"><span class="built_in">isuppper</span>(<span class="type">char</span> c);	<span class="comment">//为大写字母</span></span><br><span class="line"><span class="built_in">isdigit</span>(<span class="type">char</span> c);	<span class="comment">//是否为数字</span></span><br><span class="line"><span class="built_in">isalpha</span>(<span class="type">char</span> c);	<span class="comment">//是否为字母</span></span><br><span class="line"><span class="built_in">isalnum</span>(<span class="type">char</span> c); 	<span class="comment">//是否为字母或者数字</span></span><br><span class="line"><span class="built_in">toupper</span>(<span class="type">char</span> c); 	<span class="comment">//字母小转大</span></span><br><span class="line"><span class="built_in">tolower</span>(<span class="type">char</span> c); 	<span class="comment">//字母大转小</span></span><br></pre></td></tr></table></figure>

<hr>
<h2 id="3-3-pair-tuple-容器"><a href="#3-3-pair-tuple-容器" class="headerlink" title="3.3 pair &amp; tuple  容器"></a>3.3 pair &amp; tuple  容器</h2><p>std::pair 和 std::tuple 不是STL容器库中的容器，由于经常用到，顺便整理。pair 相当于 tuple 的特例。</p>
<ul>
<li>pair 是将2个数据组合成一个数据，当需要这样的需求时就可以使用pair，如STL中的map就是将key和value放在一起来保存。另一个应用是，当一个函数需要返回2个数据的时候，可以选择 pair。pair 的实现是一种结构体，主要的两个成员变量是 first , second。</li>
<li>tuple是C++11新标准里的类型。它是一个类似 pair 类型的模板。pair 类型是每个成员变量各自可以是任意类型，但是只能有俩个成员，而 tuple 与 pair 不同的是它可以有任意数量的成员。但是每个确定的 tuple 类型的成员数目是固定的。</li>
</ul>
<hr>

      

      
    </div>
    <div class="article-info article-info-index">
      
      
	<div class="article-tag tagcloud">
		<i class="icon-price-tags icon"></i>
		<ul class="article-tag-list">
			 
        		<li class="article-tag-list-item">
        			<a href="javascript:void(0)" class="js-tag article-tag-list-link color4">STL</a>
        		</li>
      		
		</ul>
	</div>

      

      
        <p class="article-more-link">
          <a class="article-more-a" href="/2022/06/25/STL%E6%A0%87%E5%87%86%E6%A8%A1%E7%89%88%E7%B1%BB/">展开全文 >></a>
        </p>
      

      
      <div class="clearfix"></div>
    </div>
  </div>
</article>

<aside class="wrap-side-operation">
    <div class="mod-side-operation">
        
        <div class="jump-container" id="js-jump-container" style="display:none;">
            <a href="javascript:void(0)" class="mod-side-operation__jump-to-top">
                <i class="icon-font icon-back"></i>
            </a>
            <div id="js-jump-plan-container" class="jump-plan-container" style="top: -11px;">
                <i class="icon-font icon-plane jump-plane"></i>
            </div>
        </div>
        
        
    </div>
</aside>




  
    <article id="post-远程聊天室" class="article article-type-post  article-index" itemscope itemprop="blogPost">
  <div class="article-inner">
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/2022/05/03/%E8%BF%9C%E7%A8%8B%E8%81%8A%E5%A4%A9%E5%AE%A4/">远程聊天室</a>
    </h1>
  

        
        <a href="/2022/05/03/%E8%BF%9C%E7%A8%8B%E8%81%8A%E5%A4%A9%E5%AE%A4/" class="archive-article-date">
  	<time datetime="2022-05-03T09:31:45.000Z" itemprop="datePublished"><i class="icon-calendar icon"></i>2022-05-03</time>
</a>
        
      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <hr>
<h1 id="引言"><a href="#引言" class="headerlink" title="引言"></a>引言</h1><h2 id="1-设计思路"><a href="#1-设计思路" class="headerlink" title="1.设计思路"></a>1.设计思路</h2><p>注册登录、多客户端数据传输问题（高并发）</p>
<h2 id="2-高并发额解决方案："><a href="#2-高并发额解决方案：" class="headerlink" title="2.高并发额解决方案："></a>2.高并发额解决方案：</h2><ul>
<li><p>TCP+多线程，缺点对服务器性能要求比较高</p>
</li>
<li><p>select（集合） 一个线程不断循环，对服务器性能要求比较低，但并发量比较低，处理效率比较低</p>
</li>
<li><p>epoll 并发量理论上无限，处理效率高</p>
</li>
<li><p>epoll+多线程（访问时再创建线程），频繁启动线程消耗时间资源</p>
</li>
<li><p>epoll+线程池（提前创建一定数量的线程）</p>
</li>
<li><p>libevent（有同步的机制）</p>
</li>
<li><p>libevent+多线程</p>
</li>
</ul>
<p>关于libevent，可以参考如下链接：<a target="_blank" rel="noopener" href="https://blog.csdn.net/initphp/article/details/41946061?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522169701410116800226580641%2522%252C%2522scm%2522%253A%252220140713.130102334..%2522%257D&request_id=169701410116800226580641&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~all~top_positive~default-1-41946061-null-null.142%5Ev96%5Epc_search_result_base9&utm_term=libevent&spm=1018.2226.3001.4187">libevent库的使用</a></p>
<h2 id="3-数据保存方式"><a href="#3-数据保存方式" class="headerlink" title="3.数据保存方式"></a>3.数据保存方式</h2><ul>
<li>数据库：服务器数据存储。单用户的个人信息存储和多用户的群组信息存储</li>
<li>链表：实时数据保存。用来保存当前网络在线用户以及当前网络在线群成员</li>
</ul>
<h1 id="一-轻量级服务器登录"><a href="#一-轻量级服务器登录" class="headerlink" title="一.轻量级服务器登录"></a>一.轻量级服务器登录</h1><h2 id="1-1-购买Linux服务器"><a href="#1-1-购买Linux服务器" class="headerlink" title="1.1 购买Linux服务器"></a>1.1 购买Linux服务器</h2><p>笔者购买的是腾讯云轻量服务器，系统是 Ubuntu 20.04 LTS 版本</p>
<h2 id="1-2-重置密码"><a href="#1-2-重置密码" class="headerlink" title="1.2 重置密码"></a>1.2 重置密码</h2><p>将密码重置为一个自己熟悉的密码</p>
<h2 id="1-3-设定密钥"><a href="#1-3-设定密钥" class="headerlink" title="1.3 设定密钥"></a>1.3 设定密钥</h2><p>创建密钥可以通过ssh远程登录</p>
<h2 id="1-4-ssh远程登录"><a href="#1-4-ssh远程登录" class="headerlink" title="1.4 ssh远程登录"></a>1.4 ssh远程登录</h2><ul>
<li>一种是通过密码登录</li>
<li>一种是密钥登录，此时需要将第3步中的密钥绑定到服务器系统上</li>
</ul>
<blockquote>
<p><strong>说明</strong>:Ubuntu系统ssh远程登录默认关闭了<strong>root</strong>权限，需要手动更改步骤如下：</p>
</blockquote>
<ol>
<li><p>使用 <strong>ubuntu</strong> 帐户登录轻量应用服务器。</p>
</li>
<li><p>执行以下命令，设置 <strong>root</strong> 密码。</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo passwd root</span><br></pre></td></tr></table></figure>
</li>
<li><p>输入 <strong>root</strong> 的密码，按 <strong>Enter</strong>。</p>
</li>
<li><p>重复输入 <strong>root</strong> 的密码，按 <strong>Enter</strong>。返回如下信息，即表示 <strong>root</strong> 密码设置成功。</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">passwd: password updated successfully</span><br></pre></td></tr></table></figure>
</li>
<li><p>执行以下命令，打开 <strong>sshd_config</strong> 配置文件。</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo vi /etc/ssh/sshd_config</span><br></pre></td></tr></table></figure>
</li>
<li><p>按 <strong>i</strong> 切换至编辑模式，找到 <strong>#Authentication</strong>，将 <strong>PermitRootLogin</strong> 参数修改为 <strong>yes</strong>。如果 <strong>PermitRootLogin</strong> 参数被注释，请去掉首行的注释符号 <strong>（#）</strong>。</p>
</li>
<li><p>找到 <strong>#Authentication</strong>，将 <strong>PasswordAuthentication</strong> 参数修改为 <strong>yes</strong>。说明：若 sshd_config 配置文件中无此配置项，则添加 <strong>PasswordAuthentication yes</strong> 项即可。</p>
</li>
<li><p>按 <strong>Esc</strong>，输入 <strong>:wq</strong>，保存文件并返回。</p>
</li>
<li><p>执行以下命令，重启 ssh 服务。</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo service ssh restart</span><br></pre></td></tr></table></figure>
</li>
<li><p>然后便可以在XShell上配置远程登录服务器</p>
</li>
</ol>
<h1 id="二-服务器端的环境部署"><a href="#二-服务器端的环境部署" class="headerlink" title="二.服务器端的环境部署"></a>二.服务器端的环境部署</h1><h2 id="2-1-更新源"><a href="#2-1-更新源" class="headerlink" title="2.1 更新源"></a>2.1 更新源</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo apt-get update</span><br></pre></td></tr></table></figure>

<div style="text-align: center;">
    <img src="https://dustwind-picture-upload.oss-cn-chengdu.aliyuncs.com/img/TCP%E7%BD%91%E7%BB%9C%E8%81%8A%E5%A4%A9%E5%AE%A4/%E7%8E%AF%E5%A2%83%E9%85%8D%E7%BD%AE/%E7%8E%AF%E5%A2%83%E9%85%8D%E7%BD%AE/2.%E6%9B%B4%E6%96%B0%E6%BA%90.png" alt="更新源"  />
</div>

<h2 id="2-2-安装MySQL库"><a href="#2-2-安装MySQL库" class="headerlink" title="2.2 安装MySQL库"></a>2.2 安装MySQL库</h2><p>主要是安装mysql-server、mysql-client以及libmysqlclient-dev</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo apt-get install mysql-server mysql-client libmysqlclient-dev </span><br></pre></td></tr></table></figure>

<div style="text-align: center;">
    <img src="https://dustwind-picture-upload.oss-cn-chengdu.aliyuncs.com/img/TCP%E7%BD%91%E7%BB%9C%E8%81%8A%E5%A4%A9%E5%AE%A4/%E7%8E%AF%E5%A2%83%E9%85%8D%E7%BD%AE/%E7%8E%AF%E5%A2%83%E9%85%8D%E7%BD%AE/3.%E6%9C%8D%E5%8A%A1%E5%99%A8%E7%AB%AF%E5%AE%89%E8%A3%85MySQL%E5%BA%93-1-%E5%91%BD%E4%BB%A4.png" alt="服务器端安装MySQL库"  />
</div>

<h2 id="2-3-安装libevent-dev的库"><a href="#2-3-安装libevent-dev的库" class="headerlink" title="2.3 安装libevent-dev的库"></a>2.3 安装libevent-dev的库</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo apt-get install libevent-dev</span><br></pre></td></tr></table></figure>

<div style="text-align: center;">
    <img src="https://dustwind-picture-upload.oss-cn-chengdu.aliyuncs.com/img/TCP%E7%BD%91%E7%BB%9C%E8%81%8A%E5%A4%A9%E5%AE%A4/%E7%8E%AF%E5%A2%83%E9%85%8D%E7%BD%AE/%E7%8E%AF%E5%A2%83%E9%85%8D%E7%BD%AE/4.%E6%9C%8D%E5%8A%A1%E5%99%A8%E7%AB%AF%E5%AE%89%E8%A3%85Libevent%E5%BA%93-1-%E5%91%BD%E4%BB%A4.png" alt="服务器端安装Libevent库"  />
</div>

<h2 id="2-4-安装libjsoncpp-dev库"><a href="#2-4-安装libjsoncpp-dev库" class="headerlink" title="2.4 安装libjsoncpp-dev库"></a>2.4 安装libjsoncpp-dev库</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo apt-get install libjsoncpp-dev</span><br></pre></td></tr></table></figure>

<div style="text-align: center;">
    <img src="https://dustwind-picture-upload.oss-cn-chengdu.aliyuncs.com/img/TCP%E7%BD%91%E7%BB%9C%E8%81%8A%E5%A4%A9%E5%AE%A4/%E7%8E%AF%E5%A2%83%E9%85%8D%E7%BD%AE/%E7%8E%AF%E5%A2%83%E9%85%8D%E7%BD%AE/5.%E6%9C%8D%E5%8A%A1%E5%99%A8%E7%AB%AF%E5%AE%89%E8%A3%85JSON%E5%BA%93-1-%E5%91%BD%E4%BB%A4.png" alt="服务器端安装JSON库"  />
</div>

<h2 id="2-5-安装g-gcc编译器"><a href="#2-5-安装g-gcc编译器" class="headerlink" title="2.5 安装g++&#x2F;gcc编译器"></a>2.5 安装g++&#x2F;gcc编译器</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo apt-get install gcc g++</span><br></pre></td></tr></table></figure>

<div style="text-align: center;">
    <img src="https://dustwind-picture-upload.oss-cn-chengdu.aliyuncs.com/img/TCP%E7%BD%91%E7%BB%9C%E8%81%8A%E5%A4%A9%E5%AE%A4/%E7%8E%AF%E5%A2%83%E9%85%8D%E7%BD%AE/%E7%8E%AF%E5%A2%83%E9%85%8D%E7%BD%AE/6.%E6%9C%8D%E5%8A%A1%E5%99%A8%E7%AB%AF%E5%AE%89%E8%A3%85gcc%E5%92%8Cg%2B%2B%E5%BA%93.png" alt="服务器端安装gcc和g++库"  />
</div>

<h2 id="2-6-建立两张表user和chatgroup"><a href="#2-6-建立两张表user和chatgroup" class="headerlink" title="2.6 建立两张表user和chatgroup"></a>2.6 建立两张表user和chatgroup</h2><p>运行MySQL程序：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">mysql -u root -p</span><br></pre></td></tr></table></figure>

<p>创建两个数据库用于存储用户信息以及用户群组信息：</p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">create</span> database <span class="keyword">user</span>;</span><br><span class="line"><span class="keyword">create</span> database chatgroup;</span><br></pre></td></tr></table></figure>

<div style="text-align: center;">
    <img src="https://dustwind-picture-upload.oss-cn-chengdu.aliyuncs.com/img/TCP%E7%BD%91%E7%BB%9C%E8%81%8A%E5%A4%A9%E5%AE%A4/%E7%8E%AF%E5%A2%83%E9%85%8D%E7%BD%AE/%E7%8E%AF%E5%A2%83%E9%85%8D%E7%BD%AE/7.%E5%88%9B%E5%BB%BA%E6%9C%8D%E5%8A%A1%E5%99%A8%E4%B8%A4%E4%B8%AAMySQL%E6%95%B0%E6%8D%AE%E5%BA%93.png" alt="创建两个MySQL数据库"  /></div>


      

      
    </div>
    <div class="article-info article-info-index">
      
      
	<div class="article-tag tagcloud">
		<i class="icon-price-tags icon"></i>
		<ul class="article-tag-list">
			 
        		<li class="article-tag-list-item">
        			<a href="javascript:void(0)" class="js-tag article-tag-list-link color1">C/C++</a>
        		</li>
      		
		</ul>
	</div>

      

      
        <p class="article-more-link">
          <a class="article-more-a" href="/2022/05/03/%E8%BF%9C%E7%A8%8B%E8%81%8A%E5%A4%A9%E5%AE%A4/">展开全文 >></a>
        </p>
      

      
      <div class="clearfix"></div>
    </div>
  </div>
</article>

<aside class="wrap-side-operation">
    <div class="mod-side-operation">
        
        <div class="jump-container" id="js-jump-container" style="display:none;">
            <a href="javascript:void(0)" class="mod-side-operation__jump-to-top">
                <i class="icon-font icon-back"></i>
            </a>
            <div id="js-jump-plan-container" class="jump-plan-container" style="top: -11px;">
                <i class="icon-font icon-plane jump-plane"></i>
            </div>
        </div>
        
        
    </div>
</aside>




  
  
    <nav id="page-nav">
      <span class="page-number current">1</span><a class="page-number" href="/page/2/">2</a><a class="extend next" rel="next" href="/page/2/">Next &raquo;</a>
    </nav>
  


          </div>
        </div>
      </div>
      <footer id="footer">
  <div class="outer">
    <div id="footer-info">
    	<div class="footer-left">
    		&copy; 2024 DustWind
    	</div>
      	<div class="footer-right">
      		<a href="http://hexo.io/" target="_blank">Hexo</a>  Theme <a href="https://github.com/litten/hexo-theme-yilia" target="_blank">Yilia</a> by Litten
      	</div>
    </div>
  </div>
</footer>
    </div>
    <script>
	var yiliaConfig = {
		mathjax: true,
		isHome: true,
		isPost: false,
		isArchive: false,
		isTag: false,
		isCategory: false,
		open_in_new: true,
		toc_hide_index: true,
		root: "/",
		innerArchive: true,
		showTags: true
	}
</script>

<script>!function(t){function n(e){if(r[e])return r[e].exports;var i=r[e]={exports:{},id:e,loaded:!1};return t[e].call(i.exports,i,i.exports,n),i.loaded=!0,i.exports}var r={};n.m=t,n.c=r,n.p="./",n(0)}([function(t,n,r){r(195),t.exports=r(191)},function(t,n,r){var e=r(3),i=r(52),o=r(27),u=r(28),c=r(53),f="prototype",a=function(t,n,r){var s,l,h,v,p=t&a.F,d=t&a.G,y=t&a.S,g=t&a.P,b=t&a.B,m=d?e:y?e[n]||(e[n]={}):(e[n]||{})[f],x=d?i:i[n]||(i[n]={}),w=x[f]||(x[f]={});d&&(r=n);for(s in r)l=!p&&m&&void 0!==m[s],h=(l?m:r)[s],v=b&&l?c(h,e):g&&"function"==typeof h?c(Function.call,h):h,m&&u(m,s,h,t&a.U),x[s]!=h&&o(x,s,v),g&&w[s]!=h&&(w[s]=h)};e.core=i,a.F=1,a.G=2,a.S=4,a.P=8,a.B=16,a.W=32,a.U=64,a.R=128,t.exports=a},function(t,n,r){var e=r(6);t.exports=function(t){if(!e(t))throw TypeError(t+" is not an object!");return t}},function(t,n){var r=t.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=r)},function(t,n){t.exports=function(t){try{return!!t()}catch(t){return!0}}},function(t,n){var r=t.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=r)},function(t,n){t.exports=function(t){return"object"==typeof t?null!==t:"function"==typeof t}},function(t,n,r){var e=r(126)("wks"),i=r(76),o=r(3).Symbol,u="function"==typeof o;(t.exports=function(t){return e[t]||(e[t]=u&&o[t]||(u?o:i)("Symbol."+t))}).store=e},function(t,n){var r={}.hasOwnProperty;t.exports=function(t,n){return r.call(t,n)}},function(t,n,r){var e=r(94),i=r(33);t.exports=function(t){return e(i(t))}},function(t,n,r){t.exports=!r(4)(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a})},function(t,n,r){var e=r(2),i=r(167),o=r(50),u=Object.defineProperty;n.f=r(10)?Object.defineProperty:function(t,n,r){if(e(t),n=o(n,!0),e(r),i)try{return u(t,n,r)}catch(t){}if("get"in r||"set"in r)throw TypeError("Accessors not supported!");return"value"in r&&(t[n]=r.value),t}},function(t,n,r){t.exports=!r(18)(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a})},function(t,n,r){var e=r(14),i=r(22);t.exports=r(12)?function(t,n,r){return e.f(t,n,i(1,r))}:function(t,n,r){return t[n]=r,t}},function(t,n,r){var e=r(20),i=r(58),o=r(42),u=Object.defineProperty;n.f=r(12)?Object.defineProperty:function(t,n,r){if(e(t),n=o(n,!0),e(r),i)try{return u(t,n,r)}catch(t){}if("get"in r||"set"in r)throw TypeError("Accessors not supported!");return"value"in r&&(t[n]=r.value),t}},function(t,n,r){var e=r(40)("wks"),i=r(23),o=r(5).Symbol,u="function"==typeof o;(t.exports=function(t){return e[t]||(e[t]=u&&o[t]||(u?o:i)("Symbol."+t))}).store=e},function(t,n,r){var e=r(67),i=Math.min;t.exports=function(t){return t>0?i(e(t),9007199254740991):0}},function(t,n,r){var e=r(46);t.exports=function(t){return Object(e(t))}},function(t,n){t.exports=function(t){try{return!!t()}catch(t){return!0}}},function(t,n,r){var e=r(63),i=r(34);t.exports=Object.keys||function(t){return e(t,i)}},function(t,n,r){var e=r(21);t.exports=function(t){if(!e(t))throw TypeError(t+" is not an object!");return t}},function(t,n){t.exports=function(t){return"object"==typeof t?null!==t:"function"==typeof t}},function(t,n){t.exports=function(t,n){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:n}}},function(t,n){var r=0,e=Math.random();t.exports=function(t){return"Symbol(".concat(void 0===t?"":t,")_",(++r+e).toString(36))}},function(t,n){var r={}.hasOwnProperty;t.exports=function(t,n){return r.call(t,n)}},function(t,n){var r=t.exports={version:"2.4.0"};"number"==typeof __e&&(__e=r)},function(t,n){t.exports=function(t){if("function"!=typeof t)throw TypeError(t+" is not a function!");return t}},function(t,n,r){var e=r(11),i=r(66);t.exports=r(10)?function(t,n,r){return e.f(t,n,i(1,r))}:function(t,n,r){return t[n]=r,t}},function(t,n,r){var e=r(3),i=r(27),o=r(24),u=r(76)("src"),c="toString",f=Function[c],a=(""+f).split(c);r(52).inspectSource=function(t){return f.call(t)},(t.exports=function(t,n,r,c){var f="function"==typeof r;f&&(o(r,"name")||i(r,"name",n)),t[n]!==r&&(f&&(o(r,u)||i(r,u,t[n]?""+t[n]:a.join(String(n)))),t===e?t[n]=r:c?t[n]?t[n]=r:i(t,n,r):(delete t[n],i(t,n,r)))})(Function.prototype,c,function(){return"function"==typeof this&&this[u]||f.call(this)})},function(t,n,r){var e=r(1),i=r(4),o=r(46),u=function(t,n,r,e){var i=String(o(t)),u="<"+n;return""!==r&&(u+=" "+r+'="'+String(e).replace(/"/g,"&quot;")+'"'),u+">"+i+"</"+n+">"};t.exports=function(t,n){var r={};r[t]=n(u),e(e.P+e.F*i(function(){var n=""[t]('"');return n!==n.toLowerCase()||n.split('"').length>3}),"String",r)}},function(t,n,r){var e=r(115),i=r(46);t.exports=function(t){return e(i(t))}},function(t,n,r){var e=r(116),i=r(66),o=r(30),u=r(50),c=r(24),f=r(167),a=Object.getOwnPropertyDescriptor;n.f=r(10)?a:function(t,n){if(t=o(t),n=u(n,!0),f)try{return a(t,n)}catch(t){}if(c(t,n))return i(!e.f.call(t,n),t[n])}},function(t,n,r){var e=r(24),i=r(17),o=r(145)("IE_PROTO"),u=Object.prototype;t.exports=Object.getPrototypeOf||function(t){return t=i(t),e(t,o)?t[o]:"function"==typeof t.constructor&&t instanceof t.constructor?t.constructor.prototype:t instanceof Object?u:null}},function(t,n){t.exports=function(t){if(void 0==t)throw TypeError("Can't call method on  "+t);return t}},function(t,n){t.exports="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(",")},function(t,n){t.exports={}},function(t,n){t.exports=!0},function(t,n){n.f={}.propertyIsEnumerable},function(t,n,r){var e=r(14).f,i=r(8),o=r(15)("toStringTag");t.exports=function(t,n,r){t&&!i(t=r?t:t.prototype,o)&&e(t,o,{configurable:!0,value:n})}},function(t,n,r){var e=r(40)("keys"),i=r(23);t.exports=function(t){return e[t]||(e[t]=i(t))}},function(t,n,r){var e=r(5),i="__core-js_shared__",o=e[i]||(e[i]={});t.exports=function(t){return o[t]||(o[t]={})}},function(t,n){var r=Math.ceil,e=Math.floor;t.exports=function(t){return isNaN(t=+t)?0:(t>0?e:r)(t)}},function(t,n,r){var e=r(21);t.exports=function(t,n){if(!e(t))return t;var r,i;if(n&&"function"==typeof(r=t.toString)&&!e(i=r.call(t)))return i;if("function"==typeof(r=t.valueOf)&&!e(i=r.call(t)))return i;if(!n&&"function"==typeof(r=t.toString)&&!e(i=r.call(t)))return i;throw TypeError("Can't convert object to primitive value")}},function(t,n,r){var e=r(5),i=r(25),o=r(36),u=r(44),c=r(14).f;t.exports=function(t){var n=i.Symbol||(i.Symbol=o?{}:e.Symbol||{});"_"==t.charAt(0)||t in n||c(n,t,{value:u.f(t)})}},function(t,n,r){n.f=r(15)},function(t,n){var r={}.toString;t.exports=function(t){return r.call(t).slice(8,-1)}},function(t,n){t.exports=function(t){if(void 0==t)throw TypeError("Can't call method on  "+t);return t}},function(t,n,r){var e=r(4);t.exports=function(t,n){return!!t&&e(function(){n?t.call(null,function(){},1):t.call(null)})}},function(t,n,r){var e=r(53),i=r(115),o=r(17),u=r(16),c=r(203);t.exports=function(t,n){var r=1==t,f=2==t,a=3==t,s=4==t,l=6==t,h=5==t||l,v=n||c;return function(n,c,p){for(var d,y,g=o(n),b=i(g),m=e(c,p,3),x=u(b.length),w=0,S=r?v(n,x):f?v(n,0):void 0;x>w;w++)if((h||w in b)&&(d=b[w],y=m(d,w,g),t))if(r)S[w]=y;else if(y)switch(t){case 3:return!0;case 5:return d;case 6:return w;case 2:S.push(d)}else if(s)return!1;return l?-1:a||s?s:S}}},function(t,n,r){var e=r(1),i=r(52),o=r(4);t.exports=function(t,n){var r=(i.Object||{})[t]||Object[t],u={};u[t]=n(r),e(e.S+e.F*o(function(){r(1)}),"Object",u)}},function(t,n,r){var e=r(6);t.exports=function(t,n){if(!e(t))return t;var r,i;if(n&&"function"==typeof(r=t.toString)&&!e(i=r.call(t)))return i;if("function"==typeof(r=t.valueOf)&&!e(i=r.call(t)))return i;if(!n&&"function"==typeof(r=t.toString)&&!e(i=r.call(t)))return i;throw TypeError("Can't convert object to primitive value")}},function(t,n,r){var e=r(5),i=r(25),o=r(91),u=r(13),c="prototype",f=function(t,n,r){var a,s,l,h=t&f.F,v=t&f.G,p=t&f.S,d=t&f.P,y=t&f.B,g=t&f.W,b=v?i:i[n]||(i[n]={}),m=b[c],x=v?e:p?e[n]:(e[n]||{})[c];v&&(r=n);for(a in r)(s=!h&&x&&void 0!==x[a])&&a in b||(l=s?x[a]:r[a],b[a]=v&&"function"!=typeof x[a]?r[a]:y&&s?o(l,e):g&&x[a]==l?function(t){var n=function(n,r,e){if(this instanceof t){switch(arguments.length){case 0:return new t;case 1:return new t(n);case 2:return new t(n,r)}return new t(n,r,e)}return t.apply(this,arguments)};return n[c]=t[c],n}(l):d&&"function"==typeof l?o(Function.call,l):l,d&&((b.virtual||(b.virtual={}))[a]=l,t&f.R&&m&&!m[a]&&u(m,a,l)))};f.F=1,f.G=2,f.S=4,f.P=8,f.B=16,f.W=32,f.U=64,f.R=128,t.exports=f},function(t,n){var r=t.exports={version:"2.4.0"};"number"==typeof __e&&(__e=r)},function(t,n,r){var e=r(26);t.exports=function(t,n,r){if(e(t),void 0===n)return t;switch(r){case 1:return function(r){return t.call(n,r)};case 2:return function(r,e){return t.call(n,r,e)};case 3:return function(r,e,i){return t.call(n,r,e,i)}}return function(){return t.apply(n,arguments)}}},function(t,n,r){var e=r(183),i=r(1),o=r(126)("metadata"),u=o.store||(o.store=new(r(186))),c=function(t,n,r){var i=u.get(t);if(!i){if(!r)return;u.set(t,i=new e)}var o=i.get(n);if(!o){if(!r)return;i.set(n,o=new e)}return o},f=function(t,n,r){var e=c(n,r,!1);return void 0!==e&&e.has(t)},a=function(t,n,r){var e=c(n,r,!1);return void 0===e?void 0:e.get(t)},s=function(t,n,r,e){c(r,e,!0).set(t,n)},l=function(t,n){var r=c(t,n,!1),e=[];return r&&r.forEach(function(t,n){e.push(n)}),e},h=function(t){return void 0===t||"symbol"==typeof t?t:String(t)},v=function(t){i(i.S,"Reflect",t)};t.exports={store:u,map:c,has:f,get:a,set:s,keys:l,key:h,exp:v}},function(t,n,r){"use strict";if(r(10)){var e=r(69),i=r(3),o=r(4),u=r(1),c=r(127),f=r(152),a=r(53),s=r(68),l=r(66),h=r(27),v=r(73),p=r(67),d=r(16),y=r(75),g=r(50),b=r(24),m=r(180),x=r(114),w=r(6),S=r(17),_=r(137),O=r(70),E=r(32),P=r(71).f,j=r(154),F=r(76),M=r(7),A=r(48),N=r(117),T=r(146),I=r(155),k=r(80),L=r(123),R=r(74),C=r(130),D=r(160),U=r(11),W=r(31),G=U.f,B=W.f,V=i.RangeError,z=i.TypeError,q=i.Uint8Array,K="ArrayBuffer",J="Shared"+K,Y="BYTES_PER_ELEMENT",H="prototype",$=Array[H],X=f.ArrayBuffer,Q=f.DataView,Z=A(0),tt=A(2),nt=A(3),rt=A(4),et=A(5),it=A(6),ot=N(!0),ut=N(!1),ct=I.values,ft=I.keys,at=I.entries,st=$.lastIndexOf,lt=$.reduce,ht=$.reduceRight,vt=$.join,pt=$.sort,dt=$.slice,yt=$.toString,gt=$.toLocaleString,bt=M("iterator"),mt=M("toStringTag"),xt=F("typed_constructor"),wt=F("def_constructor"),St=c.CONSTR,_t=c.TYPED,Ot=c.VIEW,Et="Wrong length!",Pt=A(1,function(t,n){return Tt(T(t,t[wt]),n)}),jt=o(function(){return 1===new q(new Uint16Array([1]).buffer)[0]}),Ft=!!q&&!!q[H].set&&o(function(){new q(1).set({})}),Mt=function(t,n){if(void 0===t)throw z(Et);var r=+t,e=d(t);if(n&&!m(r,e))throw V(Et);return e},At=function(t,n){var r=p(t);if(r<0||r%n)throw V("Wrong offset!");return r},Nt=function(t){if(w(t)&&_t in t)return t;throw z(t+" is not a typed array!")},Tt=function(t,n){if(!(w(t)&&xt in t))throw z("It is not a typed array constructor!");return new t(n)},It=function(t,n){return kt(T(t,t[wt]),n)},kt=function(t,n){for(var r=0,e=n.length,i=Tt(t,e);e>r;)i[r]=n[r++];return i},Lt=function(t,n,r){G(t,n,{get:function(){return this._d[r]}})},Rt=function(t){var n,r,e,i,o,u,c=S(t),f=arguments.length,s=f>1?arguments[1]:void 0,l=void 0!==s,h=j(c);if(void 0!=h&&!_(h)){for(u=h.call(c),e=[],n=0;!(o=u.next()).done;n++)e.push(o.value);c=e}for(l&&f>2&&(s=a(s,arguments[2],2)),n=0,r=d(c.length),i=Tt(this,r);r>n;n++)i[n]=l?s(c[n],n):c[n];return i},Ct=function(){for(var t=0,n=arguments.length,r=Tt(this,n);n>t;)r[t]=arguments[t++];return r},Dt=!!q&&o(function(){gt.call(new q(1))}),Ut=function(){return gt.apply(Dt?dt.call(Nt(this)):Nt(this),arguments)},Wt={copyWithin:function(t,n){return D.call(Nt(this),t,n,arguments.length>2?arguments[2]:void 0)},every:function(t){return rt(Nt(this),t,arguments.length>1?arguments[1]:void 0)},fill:function(t){return C.apply(Nt(this),arguments)},filter:function(t){return It(this,tt(Nt(this),t,arguments.length>1?arguments[1]:void 0))},find:function(t){return et(Nt(this),t,arguments.length>1?arguments[1]:void 0)},findIndex:function(t){return it(Nt(this),t,arguments.length>1?arguments[1]:void 0)},forEach:function(t){Z(Nt(this),t,arguments.length>1?arguments[1]:void 0)},indexOf:function(t){return ut(Nt(this),t,arguments.length>1?arguments[1]:void 0)},includes:function(t){return ot(Nt(this),t,arguments.length>1?arguments[1]:void 0)},join:function(t){return vt.apply(Nt(this),arguments)},lastIndexOf:function(t){return st.apply(Nt(this),arguments)},map:function(t){return Pt(Nt(this),t,arguments.length>1?arguments[1]:void 0)},reduce:function(t){return lt.apply(Nt(this),arguments)},reduceRight:function(t){return ht.apply(Nt(this),arguments)},reverse:function(){for(var t,n=this,r=Nt(n).length,e=Math.floor(r/2),i=0;i<e;)t=n[i],n[i++]=n[--r],n[r]=t;return n},some:function(t){return nt(Nt(this),t,arguments.length>1?arguments[1]:void 0)},sort:function(t){return pt.call(Nt(this),t)},subarray:function(t,n){var r=Nt(this),e=r.length,i=y(t,e);return new(T(r,r[wt]))(r.buffer,r.byteOffset+i*r.BYTES_PER_ELEMENT,d((void 0===n?e:y(n,e))-i))}},Gt=function(t,n){return It(this,dt.call(Nt(this),t,n))},Bt=function(t){Nt(this);var n=At(arguments[1],1),r=this.length,e=S(t),i=d(e.length),o=0;if(i+n>r)throw V(Et);for(;o<i;)this[n+o]=e[o++]},Vt={entries:function(){return at.call(Nt(this))},keys:function(){return ft.call(Nt(this))},values:function(){return ct.call(Nt(this))}},zt=function(t,n){return w(t)&&t[_t]&&"symbol"!=typeof n&&n in t&&String(+n)==String(n)},qt=function(t,n){return zt(t,n=g(n,!0))?l(2,t[n]):B(t,n)},Kt=function(t,n,r){return!(zt(t,n=g(n,!0))&&w(r)&&b(r,"value"))||b(r,"get")||b(r,"set")||r.configurable||b(r,"writable")&&!r.writable||b(r,"enumerable")&&!r.enumerable?G(t,n,r):(t[n]=r.value,t)};St||(W.f=qt,U.f=Kt),u(u.S+u.F*!St,"Object",{getOwnPropertyDescriptor:qt,defineProperty:Kt}),o(function(){yt.call({})})&&(yt=gt=function(){return vt.call(this)});var Jt=v({},Wt);v(Jt,Vt),h(Jt,bt,Vt.values),v(Jt,{slice:Gt,set:Bt,constructor:function(){},toString:yt,toLocaleString:Ut}),Lt(Jt,"buffer","b"),Lt(Jt,"byteOffset","o"),Lt(Jt,"byteLength","l"),Lt(Jt,"length","e"),G(Jt,mt,{get:function(){return this[_t]}}),t.exports=function(t,n,r,f){f=!!f;var a=t+(f?"Clamped":"")+"Array",l="Uint8Array"!=a,v="get"+t,p="set"+t,y=i[a],g=y||{},b=y&&E(y),m=!y||!c.ABV,S={},_=y&&y[H],j=function(t,r){var e=t._d;return e.v[v](r*n+e.o,jt)},F=function(t,r,e){var i=t._d;f&&(e=(e=Math.round(e))<0?0:e>255?255:255&e),i.v[p](r*n+i.o,e,jt)},M=function(t,n){G(t,n,{get:function(){return j(this,n)},set:function(t){return F(this,n,t)},enumerable:!0})};m?(y=r(function(t,r,e,i){s(t,y,a,"_d");var o,u,c,f,l=0,v=0;if(w(r)){if(!(r instanceof X||(f=x(r))==K||f==J))return _t in r?kt(y,r):Rt.call(y,r);o=r,v=At(e,n);var p=r.byteLength;if(void 0===i){if(p%n)throw V(Et);if((u=p-v)<0)throw V(Et)}else if((u=d(i)*n)+v>p)throw V(Et);c=u/n}else c=Mt(r,!0),u=c*n,o=new X(u);for(h(t,"_d",{b:o,o:v,l:u,e:c,v:new Q(o)});l<c;)M(t,l++)}),_=y[H]=O(Jt),h(_,"constructor",y)):L(function(t){new y(null),new y(t)},!0)||(y=r(function(t,r,e,i){s(t,y,a);var o;return w(r)?r instanceof X||(o=x(r))==K||o==J?void 0!==i?new g(r,At(e,n),i):void 0!==e?new g(r,At(e,n)):new g(r):_t in r?kt(y,r):Rt.call(y,r):new g(Mt(r,l))}),Z(b!==Function.prototype?P(g).concat(P(b)):P(g),function(t){t in y||h(y,t,g[t])}),y[H]=_,e||(_.constructor=y));var A=_[bt],N=!!A&&("values"==A.name||void 0==A.name),T=Vt.values;h(y,xt,!0),h(_,_t,a),h(_,Ot,!0),h(_,wt,y),(f?new y(1)[mt]==a:mt in _)||G(_,mt,{get:function(){return a}}),S[a]=y,u(u.G+u.W+u.F*(y!=g),S),u(u.S,a,{BYTES_PER_ELEMENT:n,from:Rt,of:Ct}),Y in _||h(_,Y,n),u(u.P,a,Wt),R(a),u(u.P+u.F*Ft,a,{set:Bt}),u(u.P+u.F*!N,a,Vt),u(u.P+u.F*(_.toString!=yt),a,{toString:yt}),u(u.P+u.F*o(function(){new y(1).slice()}),a,{slice:Gt}),u(u.P+u.F*(o(function(){return[1,2].toLocaleString()!=new y([1,2]).toLocaleString()})||!o(function(){_.toLocaleString.call([1,2])})),a,{toLocaleString:Ut}),k[a]=N?A:T,e||N||h(_,bt,T)}}else t.exports=function(){}},function(t,n){var r={}.toString;t.exports=function(t){return r.call(t).slice(8,-1)}},function(t,n,r){var e=r(21),i=r(5).document,o=e(i)&&e(i.createElement);t.exports=function(t){return o?i.createElement(t):{}}},function(t,n,r){t.exports=!r(12)&&!r(18)(function(){return 7!=Object.defineProperty(r(57)("div"),"a",{get:function(){return 7}}).a})},function(t,n,r){"use strict";var e=r(36),i=r(51),o=r(64),u=r(13),c=r(8),f=r(35),a=r(96),s=r(38),l=r(103),h=r(15)("iterator"),v=!([].keys&&"next"in[].keys()),p="keys",d="values",y=function(){return this};t.exports=function(t,n,r,g,b,m,x){a(r,n,g);var w,S,_,O=function(t){if(!v&&t in F)return F[t];switch(t){case p:case d:return function(){return new r(this,t)}}return function(){return new r(this,t)}},E=n+" Iterator",P=b==d,j=!1,F=t.prototype,M=F[h]||F["@@iterator"]||b&&F[b],A=M||O(b),N=b?P?O("entries"):A:void 0,T="Array"==n?F.entries||M:M;if(T&&(_=l(T.call(new t)))!==Object.prototype&&(s(_,E,!0),e||c(_,h)||u(_,h,y)),P&&M&&M.name!==d&&(j=!0,A=function(){return M.call(this)}),e&&!x||!v&&!j&&F[h]||u(F,h,A),f[n]=A,f[E]=y,b)if(w={values:P?A:O(d),keys:m?A:O(p),entries:N},x)for(S in w)S in F||o(F,S,w[S]);else i(i.P+i.F*(v||j),n,w);return w}},function(t,n,r){var e=r(20),i=r(100),o=r(34),u=r(39)("IE_PROTO"),c=function(){},f="prototype",a=function(){var t,n=r(57)("iframe"),e=o.length;for(n.style.display="none",r(93).appendChild(n),n.src="javascript:",t=n.contentWindow.document,t.open(),t.write("<script>document.F=Object<\/script>"),t.close(),a=t.F;e--;)delete a[f][o[e]];return a()};t.exports=Object.create||function(t,n){var r;return null!==t?(c[f]=e(t),r=new c,c[f]=null,r[u]=t):r=a(),void 0===n?r:i(r,n)}},function(t,n,r){var e=r(63),i=r(34).concat("length","prototype");n.f=Object.getOwnPropertyNames||function(t){return e(t,i)}},function(t,n){n.f=Object.getOwnPropertySymbols},function(t,n,r){var e=r(8),i=r(9),o=r(90)(!1),u=r(39)("IE_PROTO");t.exports=function(t,n){var r,c=i(t),f=0,a=[];for(r in c)r!=u&&e(c,r)&&a.push(r);for(;n.length>f;)e(c,r=n[f++])&&(~o(a,r)||a.push(r));return a}},function(t,n,r){t.exports=r(13)},function(t,n,r){var e=r(76)("meta"),i=r(6),o=r(24),u=r(11).f,c=0,f=Object.isExtensible||function(){return!0},a=!r(4)(function(){return f(Object.preventExtensions({}))}),s=function(t){u(t,e,{value:{i:"O"+ ++c,w:{}}})},l=function(t,n){if(!i(t))return"symbol"==typeof t?t:("string"==typeof t?"S":"P")+t;if(!o(t,e)){if(!f(t))return"F";if(!n)return"E";s(t)}return t[e].i},h=function(t,n){if(!o(t,e)){if(!f(t))return!0;if(!n)return!1;s(t)}return t[e].w},v=function(t){return a&&p.NEED&&f(t)&&!o(t,e)&&s(t),t},p=t.exports={KEY:e,NEED:!1,fastKey:l,getWeak:h,onFreeze:v}},function(t,n){t.exports=function(t,n){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:n}}},function(t,n){var r=Math.ceil,e=Math.floor;t.exports=function(t){return isNaN(t=+t)?0:(t>0?e:r)(t)}},function(t,n){t.exports=function(t,n,r,e){if(!(t instanceof n)||void 0!==e&&e in t)throw TypeError(r+": incorrect invocation!");return t}},function(t,n){t.exports=!1},function(t,n,r){var e=r(2),i=r(173),o=r(133),u=r(145)("IE_PROTO"),c=function(){},f="prototype",a=function(){var t,n=r(132)("iframe"),e=o.length;for(n.style.display="none",r(135).appendChild(n),n.src="javascript:",t=n.contentWindow.document,t.open(),t.write("<script>document.F=Object<\/script>"),t.close(),a=t.F;e--;)delete a[f][o[e]];return a()};t.exports=Object.create||function(t,n){var r;return null!==t?(c[f]=e(t),r=new c,c[f]=null,r[u]=t):r=a(),void 0===n?r:i(r,n)}},function(t,n,r){var e=r(175),i=r(133).concat("length","prototype");n.f=Object.getOwnPropertyNames||function(t){return e(t,i)}},function(t,n,r){var e=r(175),i=r(133);t.exports=Object.keys||function(t){return e(t,i)}},function(t,n,r){var e=r(28);t.exports=function(t,n,r){for(var i in n)e(t,i,n[i],r);return t}},function(t,n,r){"use strict";var e=r(3),i=r(11),o=r(10),u=r(7)("species");t.exports=function(t){var n=e[t];o&&n&&!n[u]&&i.f(n,u,{configurable:!0,get:function(){return this}})}},function(t,n,r){var e=r(67),i=Math.max,o=Math.min;t.exports=function(t,n){return t=e(t),t<0?i(t+n,0):o(t,n)}},function(t,n){var r=0,e=Math.random();t.exports=function(t){return"Symbol(".concat(void 0===t?"":t,")_",(++r+e).toString(36))}},function(t,n,r){var e=r(33);t.exports=function(t){return Object(e(t))}},function(t,n,r){var e=r(7)("unscopables"),i=Array.prototype;void 0==i[e]&&r(27)(i,e,{}),t.exports=function(t){i[e][t]=!0}},function(t,n,r){var e=r(53),i=r(169),o=r(137),u=r(2),c=r(16),f=r(154),a={},s={},n=t.exports=function(t,n,r,l,h){var v,p,d,y,g=h?function(){return t}:f(t),b=e(r,l,n?2:1),m=0;if("function"!=typeof g)throw TypeError(t+" is not iterable!");if(o(g)){for(v=c(t.length);v>m;m++)if((y=n?b(u(p=t[m])[0],p[1]):b(t[m]))===a||y===s)return y}else for(d=g.call(t);!(p=d.next()).done;)if((y=i(d,b,p.value,n))===a||y===s)return y};n.BREAK=a,n.RETURN=s},function(t,n){t.exports={}},function(t,n,r){var e=r(11).f,i=r(24),o=r(7)("toStringTag");t.exports=function(t,n,r){t&&!i(t=r?t:t.prototype,o)&&e(t,o,{configurable:!0,value:n})}},function(t,n,r){var e=r(1),i=r(46),o=r(4),u=r(150),c="["+u+"]",f="​",a=RegExp("^"+c+c+"*"),s=RegExp(c+c+"*$"),l=function(t,n,r){var i={},c=o(function(){return!!u[t]()||f[t]()!=f}),a=i[t]=c?n(h):u[t];r&&(i[r]=a),e(e.P+e.F*c,"String",i)},h=l.trim=function(t,n){return t=String(i(t)),1&n&&(t=t.replace(a,"")),2&n&&(t=t.replace(s,"")),t};t.exports=l},function(t,n,r){t.exports={default:r(86),__esModule:!0}},function(t,n,r){t.exports={default:r(87),__esModule:!0}},function(t,n,r){"use strict";function e(t){return t&&t.__esModule?t:{default:t}}n.__esModule=!0;var i=r(84),o=e(i),u=r(83),c=e(u),f="function"==typeof c.default&&"symbol"==typeof o.default?function(t){return typeof t}:function(t){return t&&"function"==typeof c.default&&t.constructor===c.default&&t!==c.default.prototype?"symbol":typeof t};n.default="function"==typeof c.default&&"symbol"===f(o.default)?function(t){return void 0===t?"undefined":f(t)}:function(t){return t&&"function"==typeof c.default&&t.constructor===c.default&&t!==c.default.prototype?"symbol":void 0===t?"undefined":f(t)}},function(t,n,r){r(110),r(108),r(111),r(112),t.exports=r(25).Symbol},function(t,n,r){r(109),r(113),t.exports=r(44).f("iterator")},function(t,n){t.exports=function(t){if("function"!=typeof t)throw TypeError(t+" is not a function!");return t}},function(t,n){t.exports=function(){}},function(t,n,r){var e=r(9),i=r(106),o=r(105);t.exports=function(t){return function(n,r,u){var c,f=e(n),a=i(f.length),s=o(u,a);if(t&&r!=r){for(;a>s;)if((c=f[s++])!=c)return!0}else for(;a>s;s++)if((t||s in f)&&f[s]===r)return t||s||0;return!t&&-1}}},function(t,n,r){var e=r(88);t.exports=function(t,n,r){if(e(t),void 0===n)return t;switch(r){case 1:return function(r){return t.call(n,r)};case 2:return function(r,e){return t.call(n,r,e)};case 3:return function(r,e,i){return t.call(n,r,e,i)}}return function(){return t.apply(n,arguments)}}},function(t,n,r){var e=r(19),i=r(62),o=r(37);t.exports=function(t){var n=e(t),r=i.f;if(r)for(var u,c=r(t),f=o.f,a=0;c.length>a;)f.call(t,u=c[a++])&&n.push(u);return n}},function(t,n,r){t.exports=r(5).document&&document.documentElement},function(t,n,r){var e=r(56);t.exports=Object("z").propertyIsEnumerable(0)?Object:function(t){return"String"==e(t)?t.split(""):Object(t)}},function(t,n,r){var e=r(56);t.exports=Array.isArray||function(t){return"Array"==e(t)}},function(t,n,r){"use strict";var e=r(60),i=r(22),o=r(38),u={};r(13)(u,r(15)("iterator"),function(){return this}),t.exports=function(t,n,r){t.prototype=e(u,{next:i(1,r)}),o(t,n+" Iterator")}},function(t,n){t.exports=function(t,n){return{value:n,done:!!t}}},function(t,n,r){var e=r(19),i=r(9);t.exports=function(t,n){for(var r,o=i(t),u=e(o),c=u.length,f=0;c>f;)if(o[r=u[f++]]===n)return r}},function(t,n,r){var e=r(23)("meta"),i=r(21),o=r(8),u=r(14).f,c=0,f=Object.isExtensible||function(){return!0},a=!r(18)(function(){return f(Object.preventExtensions({}))}),s=function(t){u(t,e,{value:{i:"O"+ ++c,w:{}}})},l=function(t,n){if(!i(t))return"symbol"==typeof t?t:("string"==typeof t?"S":"P")+t;if(!o(t,e)){if(!f(t))return"F";if(!n)return"E";s(t)}return t[e].i},h=function(t,n){if(!o(t,e)){if(!f(t))return!0;if(!n)return!1;s(t)}return t[e].w},v=function(t){return a&&p.NEED&&f(t)&&!o(t,e)&&s(t),t},p=t.exports={KEY:e,NEED:!1,fastKey:l,getWeak:h,onFreeze:v}},function(t,n,r){var e=r(14),i=r(20),o=r(19);t.exports=r(12)?Object.defineProperties:function(t,n){i(t);for(var r,u=o(n),c=u.length,f=0;c>f;)e.f(t,r=u[f++],n[r]);return t}},function(t,n,r){var e=r(37),i=r(22),o=r(9),u=r(42),c=r(8),f=r(58),a=Object.getOwnPropertyDescriptor;n.f=r(12)?a:function(t,n){if(t=o(t),n=u(n,!0),f)try{return a(t,n)}catch(t){}if(c(t,n))return i(!e.f.call(t,n),t[n])}},function(t,n,r){var e=r(9),i=r(61).f,o={}.toString,u="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[],c=function(t){try{return i(t)}catch(t){return u.slice()}};t.exports.f=function(t){return u&&"[object Window]"==o.call(t)?c(t):i(e(t))}},function(t,n,r){var e=r(8),i=r(77),o=r(39)("IE_PROTO"),u=Object.prototype;t.exports=Object.getPrototypeOf||function(t){return t=i(t),e(t,o)?t[o]:"function"==typeof t.constructor&&t instanceof t.constructor?t.constructor.prototype:t instanceof Object?u:null}},function(t,n,r){var e=r(41),i=r(33);t.exports=function(t){return function(n,r){var o,u,c=String(i(n)),f=e(r),a=c.length;return f<0||f>=a?t?"":void 0:(o=c.charCodeAt(f),o<55296||o>56319||f+1===a||(u=c.charCodeAt(f+1))<56320||u>57343?t?c.charAt(f):o:t?c.slice(f,f+2):u-56320+(o-55296<<10)+65536)}}},function(t,n,r){var e=r(41),i=Math.max,o=Math.min;t.exports=function(t,n){return t=e(t),t<0?i(t+n,0):o(t,n)}},function(t,n,r){var e=r(41),i=Math.min;t.exports=function(t){return t>0?i(e(t),9007199254740991):0}},function(t,n,r){"use strict";var e=r(89),i=r(97),o=r(35),u=r(9);t.exports=r(59)(Array,"Array",function(t,n){this._t=u(t),this._i=0,this._k=n},function(){var t=this._t,n=this._k,r=this._i++;return!t||r>=t.length?(this._t=void 0,i(1)):"keys"==n?i(0,r):"values"==n?i(0,t[r]):i(0,[r,t[r]])},"values"),o.Arguments=o.Array,e("keys"),e("values"),e("entries")},function(t,n){},function(t,n,r){"use strict";var e=r(104)(!0);r(59)(String,"String",function(t){this._t=String(t),this._i=0},function(){var t,n=this._t,r=this._i;return r>=n.length?{value:void 0,done:!0}:(t=e(n,r),this._i+=t.length,{value:t,done:!1})})},function(t,n,r){"use strict";var e=r(5),i=r(8),o=r(12),u=r(51),c=r(64),f=r(99).KEY,a=r(18),s=r(40),l=r(38),h=r(23),v=r(15),p=r(44),d=r(43),y=r(98),g=r(92),b=r(95),m=r(20),x=r(9),w=r(42),S=r(22),_=r(60),O=r(102),E=r(101),P=r(14),j=r(19),F=E.f,M=P.f,A=O.f,N=e.Symbol,T=e.JSON,I=T&&T.stringify,k="prototype",L=v("_hidden"),R=v("toPrimitive"),C={}.propertyIsEnumerable,D=s("symbol-registry"),U=s("symbols"),W=s("op-symbols"),G=Object[k],B="function"==typeof N,V=e.QObject,z=!V||!V[k]||!V[k].findChild,q=o&&a(function(){return 7!=_(M({},"a",{get:function(){return M(this,"a",{value:7}).a}})).a})?function(t,n,r){var e=F(G,n);e&&delete G[n],M(t,n,r),e&&t!==G&&M(G,n,e)}:M,K=function(t){var n=U[t]=_(N[k]);return n._k=t,n},J=B&&"symbol"==typeof N.iterator?function(t){return"symbol"==typeof t}:function(t){return t instanceof N},Y=function(t,n,r){return t===G&&Y(W,n,r),m(t),n=w(n,!0),m(r),i(U,n)?(r.enumerable?(i(t,L)&&t[L][n]&&(t[L][n]=!1),r=_(r,{enumerable:S(0,!1)})):(i(t,L)||M(t,L,S(1,{})),t[L][n]=!0),q(t,n,r)):M(t,n,r)},H=function(t,n){m(t);for(var r,e=g(n=x(n)),i=0,o=e.length;o>i;)Y(t,r=e[i++],n[r]);return t},$=function(t,n){return void 0===n?_(t):H(_(t),n)},X=function(t){var n=C.call(this,t=w(t,!0));return!(this===G&&i(U,t)&&!i(W,t))&&(!(n||!i(this,t)||!i(U,t)||i(this,L)&&this[L][t])||n)},Q=function(t,n){if(t=x(t),n=w(n,!0),t!==G||!i(U,n)||i(W,n)){var r=F(t,n);return!r||!i(U,n)||i(t,L)&&t[L][n]||(r.enumerable=!0),r}},Z=function(t){for(var n,r=A(x(t)),e=[],o=0;r.length>o;)i(U,n=r[o++])||n==L||n==f||e.push(n);return e},tt=function(t){for(var n,r=t===G,e=A(r?W:x(t)),o=[],u=0;e.length>u;)!i(U,n=e[u++])||r&&!i(G,n)||o.push(U[n]);return o};B||(N=function(){if(this instanceof N)throw TypeError("Symbol is not a constructor!");var t=h(arguments.length>0?arguments[0]:void 0),n=function(r){this===G&&n.call(W,r),i(this,L)&&i(this[L],t)&&(this[L][t]=!1),q(this,t,S(1,r))};return o&&z&&q(G,t,{configurable:!0,set:n}),K(t)},c(N[k],"toString",function(){return this._k}),E.f=Q,P.f=Y,r(61).f=O.f=Z,r(37).f=X,r(62).f=tt,o&&!r(36)&&c(G,"propertyIsEnumerable",X,!0),p.f=function(t){return K(v(t))}),u(u.G+u.W+u.F*!B,{Symbol:N});for(var nt="hasInstance,isConcatSpreadable,iterator,match,replace,search,species,split,toPrimitive,toStringTag,unscopables".split(","),rt=0;nt.length>rt;)v(nt[rt++]);for(var nt=j(v.store),rt=0;nt.length>rt;)d(nt[rt++]);u(u.S+u.F*!B,"Symbol",{for:function(t){return i(D,t+="")?D[t]:D[t]=N(t)},keyFor:function(t){if(J(t))return y(D,t);throw TypeError(t+" is not a symbol!")},useSetter:function(){z=!0},useSimple:function(){z=!1}}),u(u.S+u.F*!B,"Object",{create:$,defineProperty:Y,defineProperties:H,getOwnPropertyDescriptor:Q,getOwnPropertyNames:Z,getOwnPropertySymbols:tt}),T&&u(u.S+u.F*(!B||a(function(){var t=N();return"[null]"!=I([t])||"{}"!=I({a:t})||"{}"!=I(Object(t))})),"JSON",{stringify:function(t){if(void 0!==t&&!J(t)){for(var n,r,e=[t],i=1;arguments.length>i;)e.push(arguments[i++]);return n=e[1],"function"==typeof n&&(r=n),!r&&b(n)||(n=function(t,n){if(r&&(n=r.call(this,t,n)),!J(n))return n}),e[1]=n,I.apply(T,e)}}}),N[k][R]||r(13)(N[k],R,N[k].valueOf),l(N,"Symbol"),l(Math,"Math",!0),l(e.JSON,"JSON",!0)},function(t,n,r){r(43)("asyncIterator")},function(t,n,r){r(43)("observable")},function(t,n,r){r(107);for(var e=r(5),i=r(13),o=r(35),u=r(15)("toStringTag"),c=["NodeList","DOMTokenList","MediaList","StyleSheetList","CSSRuleList"],f=0;f<5;f++){var a=c[f],s=e[a],l=s&&s.prototype;l&&!l[u]&&i(l,u,a),o[a]=o.Array}},function(t,n,r){var e=r(45),i=r(7)("toStringTag"),o="Arguments"==e(function(){return arguments}()),u=function(t,n){try{return t[n]}catch(t){}};t.exports=function(t){var n,r,c;return void 0===t?"Undefined":null===t?"Null":"string"==typeof(r=u(n=Object(t),i))?r:o?e(n):"Object"==(c=e(n))&&"function"==typeof n.callee?"Arguments":c}},function(t,n,r){var e=r(45);t.exports=Object("z").propertyIsEnumerable(0)?Object:function(t){return"String"==e(t)?t.split(""):Object(t)}},function(t,n){n.f={}.propertyIsEnumerable},function(t,n,r){var e=r(30),i=r(16),o=r(75);t.exports=function(t){return function(n,r,u){var c,f=e(n),a=i(f.length),s=o(u,a);if(t&&r!=r){for(;a>s;)if((c=f[s++])!=c)return!0}else for(;a>s;s++)if((t||s in f)&&f[s]===r)return t||s||0;return!t&&-1}}},function(t,n,r){"use strict";var e=r(3),i=r(1),o=r(28),u=r(73),c=r(65),f=r(79),a=r(68),s=r(6),l=r(4),h=r(123),v=r(81),p=r(136);t.exports=function(t,n,r,d,y,g){var b=e[t],m=b,x=y?"set":"add",w=m&&m.prototype,S={},_=function(t){var n=w[t];o(w,t,"delete"==t?function(t){return!(g&&!s(t))&&n.call(this,0===t?0:t)}:"has"==t?function(t){return!(g&&!s(t))&&n.call(this,0===t?0:t)}:"get"==t?function(t){return g&&!s(t)?void 0:n.call(this,0===t?0:t)}:"add"==t?function(t){return n.call(this,0===t?0:t),this}:function(t,r){return n.call(this,0===t?0:t,r),this})};if("function"==typeof m&&(g||w.forEach&&!l(function(){(new m).entries().next()}))){var O=new m,E=O[x](g?{}:-0,1)!=O,P=l(function(){O.has(1)}),j=h(function(t){new m(t)}),F=!g&&l(function(){for(var t=new m,n=5;n--;)t[x](n,n);return!t.has(-0)});j||(m=n(function(n,r){a(n,m,t);var e=p(new b,n,m);return void 0!=r&&f(r,y,e[x],e),e}),m.prototype=w,w.constructor=m),(P||F)&&(_("delete"),_("has"),y&&_("get")),(F||E)&&_(x),g&&w.clear&&delete w.clear}else m=d.getConstructor(n,t,y,x),u(m.prototype,r),c.NEED=!0;return v(m,t),S[t]=m,i(i.G+i.W+i.F*(m!=b),S),g||d.setStrong(m,t,y),m}},function(t,n,r){"use strict";var e=r(27),i=r(28),o=r(4),u=r(46),c=r(7);t.exports=function(t,n,r){var f=c(t),a=r(u,f,""[t]),s=a[0],l=a[1];o(function(){var n={};return n[f]=function(){return 7},7!=""[t](n)})&&(i(String.prototype,t,s),e(RegExp.prototype,f,2==n?function(t,n){return l.call(t,this,n)}:function(t){return l.call(t,this)}))}
},function(t,n,r){"use strict";var e=r(2);t.exports=function(){var t=e(this),n="";return t.global&&(n+="g"),t.ignoreCase&&(n+="i"),t.multiline&&(n+="m"),t.unicode&&(n+="u"),t.sticky&&(n+="y"),n}},function(t,n){t.exports=function(t,n,r){var e=void 0===r;switch(n.length){case 0:return e?t():t.call(r);case 1:return e?t(n[0]):t.call(r,n[0]);case 2:return e?t(n[0],n[1]):t.call(r,n[0],n[1]);case 3:return e?t(n[0],n[1],n[2]):t.call(r,n[0],n[1],n[2]);case 4:return e?t(n[0],n[1],n[2],n[3]):t.call(r,n[0],n[1],n[2],n[3])}return t.apply(r,n)}},function(t,n,r){var e=r(6),i=r(45),o=r(7)("match");t.exports=function(t){var n;return e(t)&&(void 0!==(n=t[o])?!!n:"RegExp"==i(t))}},function(t,n,r){var e=r(7)("iterator"),i=!1;try{var o=[7][e]();o.return=function(){i=!0},Array.from(o,function(){throw 2})}catch(t){}t.exports=function(t,n){if(!n&&!i)return!1;var r=!1;try{var o=[7],u=o[e]();u.next=function(){return{done:r=!0}},o[e]=function(){return u},t(o)}catch(t){}return r}},function(t,n,r){t.exports=r(69)||!r(4)(function(){var t=Math.random();__defineSetter__.call(null,t,function(){}),delete r(3)[t]})},function(t,n){n.f=Object.getOwnPropertySymbols},function(t,n,r){var e=r(3),i="__core-js_shared__",o=e[i]||(e[i]={});t.exports=function(t){return o[t]||(o[t]={})}},function(t,n,r){for(var e,i=r(3),o=r(27),u=r(76),c=u("typed_array"),f=u("view"),a=!(!i.ArrayBuffer||!i.DataView),s=a,l=0,h="Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array".split(",");l<9;)(e=i[h[l++]])?(o(e.prototype,c,!0),o(e.prototype,f,!0)):s=!1;t.exports={ABV:a,CONSTR:s,TYPED:c,VIEW:f}},function(t,n){"use strict";var r={versions:function(){var t=window.navigator.userAgent;return{trident:t.indexOf("Trident")>-1,presto:t.indexOf("Presto")>-1,webKit:t.indexOf("AppleWebKit")>-1,gecko:t.indexOf("Gecko")>-1&&-1==t.indexOf("KHTML"),mobile:!!t.match(/AppleWebKit.*Mobile.*/),ios:!!t.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/),android:t.indexOf("Android")>-1||t.indexOf("Linux")>-1,iPhone:t.indexOf("iPhone")>-1||t.indexOf("Mac")>-1,iPad:t.indexOf("iPad")>-1,webApp:-1==t.indexOf("Safari"),weixin:-1==t.indexOf("MicroMessenger")}}()};t.exports=r},function(t,n,r){"use strict";var e=r(85),i=function(t){return t&&t.__esModule?t:{default:t}}(e),o=function(){function t(t,n,e){return n||e?String.fromCharCode(n||e):r[t]||t}function n(t){return e[t]}var r={"&quot;":'"',"&lt;":"<","&gt;":">","&amp;":"&","&nbsp;":" "},e={};for(var u in r)e[r[u]]=u;return r["&apos;"]="'",e["'"]="&#39;",{encode:function(t){return t?(""+t).replace(/['<> "&]/g,n).replace(/\r?\n/g,"<br/>").replace(/\s/g,"&nbsp;"):""},decode:function(n){return n?(""+n).replace(/<br\s*\/?>/gi,"\n").replace(/&quot;|&lt;|&gt;|&amp;|&nbsp;|&apos;|&#(\d+);|&#(\d+)/g,t).replace(/\u00a0/g," "):""},encodeBase16:function(t){if(!t)return t;t+="";for(var n=[],r=0,e=t.length;e>r;r++)n.push(t.charCodeAt(r).toString(16).toUpperCase());return n.join("")},encodeBase16forJSON:function(t){if(!t)return t;t=t.replace(/[\u4E00-\u9FBF]/gi,function(t){return escape(t).replace("%u","\\u")});for(var n=[],r=0,e=t.length;e>r;r++)n.push(t.charCodeAt(r).toString(16).toUpperCase());return n.join("")},decodeBase16:function(t){if(!t)return t;t+="";for(var n=[],r=0,e=t.length;e>r;r+=2)n.push(String.fromCharCode("0x"+t.slice(r,r+2)));return n.join("")},encodeObject:function(t){if(t instanceof Array)for(var n=0,r=t.length;r>n;n++)t[n]=o.encodeObject(t[n]);else if("object"==(void 0===t?"undefined":(0,i.default)(t)))for(var e in t)t[e]=o.encodeObject(t[e]);else if("string"==typeof t)return o.encode(t);return t},loadScript:function(t){var n=document.createElement("script");document.getElementsByTagName("body")[0].appendChild(n),n.setAttribute("src",t)},addLoadEvent:function(t){var n=window.onload;"function"!=typeof window.onload?window.onload=t:window.onload=function(){n(),t()}}}}();t.exports=o},function(t,n,r){"use strict";var e=r(17),i=r(75),o=r(16);t.exports=function(t){for(var n=e(this),r=o(n.length),u=arguments.length,c=i(u>1?arguments[1]:void 0,r),f=u>2?arguments[2]:void 0,a=void 0===f?r:i(f,r);a>c;)n[c++]=t;return n}},function(t,n,r){"use strict";var e=r(11),i=r(66);t.exports=function(t,n,r){n in t?e.f(t,n,i(0,r)):t[n]=r}},function(t,n,r){var e=r(6),i=r(3).document,o=e(i)&&e(i.createElement);t.exports=function(t){return o?i.createElement(t):{}}},function(t,n){t.exports="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(",")},function(t,n,r){var e=r(7)("match");t.exports=function(t){var n=/./;try{"/./"[t](n)}catch(r){try{return n[e]=!1,!"/./"[t](n)}catch(t){}}return!0}},function(t,n,r){t.exports=r(3).document&&document.documentElement},function(t,n,r){var e=r(6),i=r(144).set;t.exports=function(t,n,r){var o,u=n.constructor;return u!==r&&"function"==typeof u&&(o=u.prototype)!==r.prototype&&e(o)&&i&&i(t,o),t}},function(t,n,r){var e=r(80),i=r(7)("iterator"),o=Array.prototype;t.exports=function(t){return void 0!==t&&(e.Array===t||o[i]===t)}},function(t,n,r){var e=r(45);t.exports=Array.isArray||function(t){return"Array"==e(t)}},function(t,n,r){"use strict";var e=r(70),i=r(66),o=r(81),u={};r(27)(u,r(7)("iterator"),function(){return this}),t.exports=function(t,n,r){t.prototype=e(u,{next:i(1,r)}),o(t,n+" Iterator")}},function(t,n,r){"use strict";var e=r(69),i=r(1),o=r(28),u=r(27),c=r(24),f=r(80),a=r(139),s=r(81),l=r(32),h=r(7)("iterator"),v=!([].keys&&"next"in[].keys()),p="keys",d="values",y=function(){return this};t.exports=function(t,n,r,g,b,m,x){a(r,n,g);var w,S,_,O=function(t){if(!v&&t in F)return F[t];switch(t){case p:case d:return function(){return new r(this,t)}}return function(){return new r(this,t)}},E=n+" Iterator",P=b==d,j=!1,F=t.prototype,M=F[h]||F["@@iterator"]||b&&F[b],A=M||O(b),N=b?P?O("entries"):A:void 0,T="Array"==n?F.entries||M:M;if(T&&(_=l(T.call(new t)))!==Object.prototype&&(s(_,E,!0),e||c(_,h)||u(_,h,y)),P&&M&&M.name!==d&&(j=!0,A=function(){return M.call(this)}),e&&!x||!v&&!j&&F[h]||u(F,h,A),f[n]=A,f[E]=y,b)if(w={values:P?A:O(d),keys:m?A:O(p),entries:N},x)for(S in w)S in F||o(F,S,w[S]);else i(i.P+i.F*(v||j),n,w);return w}},function(t,n){var r=Math.expm1;t.exports=!r||r(10)>22025.465794806718||r(10)<22025.465794806718||-2e-17!=r(-2e-17)?function(t){return 0==(t=+t)?t:t>-1e-6&&t<1e-6?t+t*t/2:Math.exp(t)-1}:r},function(t,n){t.exports=Math.sign||function(t){return 0==(t=+t)||t!=t?t:t<0?-1:1}},function(t,n,r){var e=r(3),i=r(151).set,o=e.MutationObserver||e.WebKitMutationObserver,u=e.process,c=e.Promise,f="process"==r(45)(u);t.exports=function(){var t,n,r,a=function(){var e,i;for(f&&(e=u.domain)&&e.exit();t;){i=t.fn,t=t.next;try{i()}catch(e){throw t?r():n=void 0,e}}n=void 0,e&&e.enter()};if(f)r=function(){u.nextTick(a)};else if(o){var s=!0,l=document.createTextNode("");new o(a).observe(l,{characterData:!0}),r=function(){l.data=s=!s}}else if(c&&c.resolve){var h=c.resolve();r=function(){h.then(a)}}else r=function(){i.call(e,a)};return function(e){var i={fn:e,next:void 0};n&&(n.next=i),t||(t=i,r()),n=i}}},function(t,n,r){var e=r(6),i=r(2),o=function(t,n){if(i(t),!e(n)&&null!==n)throw TypeError(n+": can't set as prototype!")};t.exports={set:Object.setPrototypeOf||("__proto__"in{}?function(t,n,e){try{e=r(53)(Function.call,r(31).f(Object.prototype,"__proto__").set,2),e(t,[]),n=!(t instanceof Array)}catch(t){n=!0}return function(t,r){return o(t,r),n?t.__proto__=r:e(t,r),t}}({},!1):void 0),check:o}},function(t,n,r){var e=r(126)("keys"),i=r(76);t.exports=function(t){return e[t]||(e[t]=i(t))}},function(t,n,r){var e=r(2),i=r(26),o=r(7)("species");t.exports=function(t,n){var r,u=e(t).constructor;return void 0===u||void 0==(r=e(u)[o])?n:i(r)}},function(t,n,r){var e=r(67),i=r(46);t.exports=function(t){return function(n,r){var o,u,c=String(i(n)),f=e(r),a=c.length;return f<0||f>=a?t?"":void 0:(o=c.charCodeAt(f),o<55296||o>56319||f+1===a||(u=c.charCodeAt(f+1))<56320||u>57343?t?c.charAt(f):o:t?c.slice(f,f+2):u-56320+(o-55296<<10)+65536)}}},function(t,n,r){var e=r(122),i=r(46);t.exports=function(t,n,r){if(e(n))throw TypeError("String#"+r+" doesn't accept regex!");return String(i(t))}},function(t,n,r){"use strict";var e=r(67),i=r(46);t.exports=function(t){var n=String(i(this)),r="",o=e(t);if(o<0||o==1/0)throw RangeError("Count can't be negative");for(;o>0;(o>>>=1)&&(n+=n))1&o&&(r+=n);return r}},function(t,n){t.exports="\t\n\v\f\r   ᠎             　\u2028\u2029\ufeff"},function(t,n,r){var e,i,o,u=r(53),c=r(121),f=r(135),a=r(132),s=r(3),l=s.process,h=s.setImmediate,v=s.clearImmediate,p=s.MessageChannel,d=0,y={},g="onreadystatechange",b=function(){var t=+this;if(y.hasOwnProperty(t)){var n=y[t];delete y[t],n()}},m=function(t){b.call(t.data)};h&&v||(h=function(t){for(var n=[],r=1;arguments.length>r;)n.push(arguments[r++]);return y[++d]=function(){c("function"==typeof t?t:Function(t),n)},e(d),d},v=function(t){delete y[t]},"process"==r(45)(l)?e=function(t){l.nextTick(u(b,t,1))}:p?(i=new p,o=i.port2,i.port1.onmessage=m,e=u(o.postMessage,o,1)):s.addEventListener&&"function"==typeof postMessage&&!s.importScripts?(e=function(t){s.postMessage(t+"","*")},s.addEventListener("message",m,!1)):e=g in a("script")?function(t){f.appendChild(a("script"))[g]=function(){f.removeChild(this),b.call(t)}}:function(t){setTimeout(u(b,t,1),0)}),t.exports={set:h,clear:v}},function(t,n,r){"use strict";var e=r(3),i=r(10),o=r(69),u=r(127),c=r(27),f=r(73),a=r(4),s=r(68),l=r(67),h=r(16),v=r(71).f,p=r(11).f,d=r(130),y=r(81),g="ArrayBuffer",b="DataView",m="prototype",x="Wrong length!",w="Wrong index!",S=e[g],_=e[b],O=e.Math,E=e.RangeError,P=e.Infinity,j=S,F=O.abs,M=O.pow,A=O.floor,N=O.log,T=O.LN2,I="buffer",k="byteLength",L="byteOffset",R=i?"_b":I,C=i?"_l":k,D=i?"_o":L,U=function(t,n,r){var e,i,o,u=Array(r),c=8*r-n-1,f=(1<<c)-1,a=f>>1,s=23===n?M(2,-24)-M(2,-77):0,l=0,h=t<0||0===t&&1/t<0?1:0;for(t=F(t),t!=t||t===P?(i=t!=t?1:0,e=f):(e=A(N(t)/T),t*(o=M(2,-e))<1&&(e--,o*=2),t+=e+a>=1?s/o:s*M(2,1-a),t*o>=2&&(e++,o/=2),e+a>=f?(i=0,e=f):e+a>=1?(i=(t*o-1)*M(2,n),e+=a):(i=t*M(2,a-1)*M(2,n),e=0));n>=8;u[l++]=255&i,i/=256,n-=8);for(e=e<<n|i,c+=n;c>0;u[l++]=255&e,e/=256,c-=8);return u[--l]|=128*h,u},W=function(t,n,r){var e,i=8*r-n-1,o=(1<<i)-1,u=o>>1,c=i-7,f=r-1,a=t[f--],s=127&a;for(a>>=7;c>0;s=256*s+t[f],f--,c-=8);for(e=s&(1<<-c)-1,s>>=-c,c+=n;c>0;e=256*e+t[f],f--,c-=8);if(0===s)s=1-u;else{if(s===o)return e?NaN:a?-P:P;e+=M(2,n),s-=u}return(a?-1:1)*e*M(2,s-n)},G=function(t){return t[3]<<24|t[2]<<16|t[1]<<8|t[0]},B=function(t){return[255&t]},V=function(t){return[255&t,t>>8&255]},z=function(t){return[255&t,t>>8&255,t>>16&255,t>>24&255]},q=function(t){return U(t,52,8)},K=function(t){return U(t,23,4)},J=function(t,n,r){p(t[m],n,{get:function(){return this[r]}})},Y=function(t,n,r,e){var i=+r,o=l(i);if(i!=o||o<0||o+n>t[C])throw E(w);var u=t[R]._b,c=o+t[D],f=u.slice(c,c+n);return e?f:f.reverse()},H=function(t,n,r,e,i,o){var u=+r,c=l(u);if(u!=c||c<0||c+n>t[C])throw E(w);for(var f=t[R]._b,a=c+t[D],s=e(+i),h=0;h<n;h++)f[a+h]=s[o?h:n-h-1]},$=function(t,n){s(t,S,g);var r=+n,e=h(r);if(r!=e)throw E(x);return e};if(u.ABV){if(!a(function(){new S})||!a(function(){new S(.5)})){S=function(t){return new j($(this,t))};for(var X,Q=S[m]=j[m],Z=v(j),tt=0;Z.length>tt;)(X=Z[tt++])in S||c(S,X,j[X]);o||(Q.constructor=S)}var nt=new _(new S(2)),rt=_[m].setInt8;nt.setInt8(0,2147483648),nt.setInt8(1,2147483649),!nt.getInt8(0)&&nt.getInt8(1)||f(_[m],{setInt8:function(t,n){rt.call(this,t,n<<24>>24)},setUint8:function(t,n){rt.call(this,t,n<<24>>24)}},!0)}else S=function(t){var n=$(this,t);this._b=d.call(Array(n),0),this[C]=n},_=function(t,n,r){s(this,_,b),s(t,S,b);var e=t[C],i=l(n);if(i<0||i>e)throw E("Wrong offset!");if(r=void 0===r?e-i:h(r),i+r>e)throw E(x);this[R]=t,this[D]=i,this[C]=r},i&&(J(S,k,"_l"),J(_,I,"_b"),J(_,k,"_l"),J(_,L,"_o")),f(_[m],{getInt8:function(t){return Y(this,1,t)[0]<<24>>24},getUint8:function(t){return Y(this,1,t)[0]},getInt16:function(t){var n=Y(this,2,t,arguments[1]);return(n[1]<<8|n[0])<<16>>16},getUint16:function(t){var n=Y(this,2,t,arguments[1]);return n[1]<<8|n[0]},getInt32:function(t){return G(Y(this,4,t,arguments[1]))},getUint32:function(t){return G(Y(this,4,t,arguments[1]))>>>0},getFloat32:function(t){return W(Y(this,4,t,arguments[1]),23,4)},getFloat64:function(t){return W(Y(this,8,t,arguments[1]),52,8)},setInt8:function(t,n){H(this,1,t,B,n)},setUint8:function(t,n){H(this,1,t,B,n)},setInt16:function(t,n){H(this,2,t,V,n,arguments[2])},setUint16:function(t,n){H(this,2,t,V,n,arguments[2])},setInt32:function(t,n){H(this,4,t,z,n,arguments[2])},setUint32:function(t,n){H(this,4,t,z,n,arguments[2])},setFloat32:function(t,n){H(this,4,t,K,n,arguments[2])},setFloat64:function(t,n){H(this,8,t,q,n,arguments[2])}});y(S,g),y(_,b),c(_[m],u.VIEW,!0),n[g]=S,n[b]=_},function(t,n,r){var e=r(3),i=r(52),o=r(69),u=r(182),c=r(11).f;t.exports=function(t){var n=i.Symbol||(i.Symbol=o?{}:e.Symbol||{});"_"==t.charAt(0)||t in n||c(n,t,{value:u.f(t)})}},function(t,n,r){var e=r(114),i=r(7)("iterator"),o=r(80);t.exports=r(52).getIteratorMethod=function(t){if(void 0!=t)return t[i]||t["@@iterator"]||o[e(t)]}},function(t,n,r){"use strict";var e=r(78),i=r(170),o=r(80),u=r(30);t.exports=r(140)(Array,"Array",function(t,n){this._t=u(t),this._i=0,this._k=n},function(){var t=this._t,n=this._k,r=this._i++;return!t||r>=t.length?(this._t=void 0,i(1)):"keys"==n?i(0,r):"values"==n?i(0,t[r]):i(0,[r,t[r]])},"values"),o.Arguments=o.Array,e("keys"),e("values"),e("entries")},function(t,n){function r(t,n){t.classList?t.classList.add(n):t.className+=" "+n}t.exports=r},function(t,n){function r(t,n){if(t.classList)t.classList.remove(n);else{var r=new RegExp("(^|\\b)"+n.split(" ").join("|")+"(\\b|$)","gi");t.className=t.className.replace(r," ")}}t.exports=r},function(t,n){function r(){throw new Error("setTimeout has not been defined")}function e(){throw new Error("clearTimeout has not been defined")}function i(t){if(s===setTimeout)return setTimeout(t,0);if((s===r||!s)&&setTimeout)return s=setTimeout,setTimeout(t,0);try{return s(t,0)}catch(n){try{return s.call(null,t,0)}catch(n){return s.call(this,t,0)}}}function o(t){if(l===clearTimeout)return clearTimeout(t);if((l===e||!l)&&clearTimeout)return l=clearTimeout,clearTimeout(t);try{return l(t)}catch(n){try{return l.call(null,t)}catch(n){return l.call(this,t)}}}function u(){d&&v&&(d=!1,v.length?p=v.concat(p):y=-1,p.length&&c())}function c(){if(!d){var t=i(u);d=!0;for(var n=p.length;n;){for(v=p,p=[];++y<n;)v&&v[y].run();y=-1,n=p.length}v=null,d=!1,o(t)}}function f(t,n){this.fun=t,this.array=n}function a(){}var s,l,h=t.exports={};!function(){try{s="function"==typeof setTimeout?setTimeout:r}catch(t){s=r}try{l="function"==typeof clearTimeout?clearTimeout:e}catch(t){l=e}}();var v,p=[],d=!1,y=-1;h.nextTick=function(t){var n=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)n[r-1]=arguments[r];p.push(new f(t,n)),1!==p.length||d||i(c)},f.prototype.run=function(){this.fun.apply(null,this.array)},h.title="browser",h.browser=!0,h.env={},h.argv=[],h.version="",h.versions={},h.on=a,h.addListener=a,h.once=a,h.off=a,h.removeListener=a,h.removeAllListeners=a,h.emit=a,h.prependListener=a,h.prependOnceListener=a,h.listeners=function(t){return[]},h.binding=function(t){throw new Error("process.binding is not supported")},h.cwd=function(){return"/"},h.chdir=function(t){throw new Error("process.chdir is not supported")},h.umask=function(){return 0}},function(t,n,r){var e=r(45);t.exports=function(t,n){if("number"!=typeof t&&"Number"!=e(t))throw TypeError(n);return+t}},function(t,n,r){"use strict";var e=r(17),i=r(75),o=r(16);t.exports=[].copyWithin||function(t,n){var r=e(this),u=o(r.length),c=i(t,u),f=i(n,u),a=arguments.length>2?arguments[2]:void 0,s=Math.min((void 0===a?u:i(a,u))-f,u-c),l=1;for(f<c&&c<f+s&&(l=-1,f+=s-1,c+=s-1);s-- >0;)f in r?r[c]=r[f]:delete r[c],c+=l,f+=l;return r}},function(t,n,r){var e=r(79);t.exports=function(t,n){var r=[];return e(t,!1,r.push,r,n),r}},function(t,n,r){var e=r(26),i=r(17),o=r(115),u=r(16);t.exports=function(t,n,r,c,f){e(n);var a=i(t),s=o(a),l=u(a.length),h=f?l-1:0,v=f?-1:1;if(r<2)for(;;){if(h in s){c=s[h],h+=v;break}if(h+=v,f?h<0:l<=h)throw TypeError("Reduce of empty array with no initial value")}for(;f?h>=0:l>h;h+=v)h in s&&(c=n(c,s[h],h,a));return c}},function(t,n,r){"use strict";var e=r(26),i=r(6),o=r(121),u=[].slice,c={},f=function(t,n,r){if(!(n in c)){for(var e=[],i=0;i<n;i++)e[i]="a["+i+"]";c[n]=Function("F,a","return new F("+e.join(",")+")")}return c[n](t,r)};t.exports=Function.bind||function(t){var n=e(this),r=u.call(arguments,1),c=function(){var e=r.concat(u.call(arguments));return this instanceof c?f(n,e.length,e):o(n,e,t)};return i(n.prototype)&&(c.prototype=n.prototype),c}},function(t,n,r){"use strict";var e=r(11).f,i=r(70),o=r(73),u=r(53),c=r(68),f=r(46),a=r(79),s=r(140),l=r(170),h=r(74),v=r(10),p=r(65).fastKey,d=v?"_s":"size",y=function(t,n){var r,e=p(n);if("F"!==e)return t._i[e];for(r=t._f;r;r=r.n)if(r.k==n)return r};t.exports={getConstructor:function(t,n,r,s){var l=t(function(t,e){c(t,l,n,"_i"),t._i=i(null),t._f=void 0,t._l=void 0,t[d]=0,void 0!=e&&a(e,r,t[s],t)});return o(l.prototype,{clear:function(){for(var t=this,n=t._i,r=t._f;r;r=r.n)r.r=!0,r.p&&(r.p=r.p.n=void 0),delete n[r.i];t._f=t._l=void 0,t[d]=0},delete:function(t){var n=this,r=y(n,t);if(r){var e=r.n,i=r.p;delete n._i[r.i],r.r=!0,i&&(i.n=e),e&&(e.p=i),n._f==r&&(n._f=e),n._l==r&&(n._l=i),n[d]--}return!!r},forEach:function(t){c(this,l,"forEach");for(var n,r=u(t,arguments.length>1?arguments[1]:void 0,3);n=n?n.n:this._f;)for(r(n.v,n.k,this);n&&n.r;)n=n.p},has:function(t){return!!y(this,t)}}),v&&e(l.prototype,"size",{get:function(){return f(this[d])}}),l},def:function(t,n,r){var e,i,o=y(t,n);return o?o.v=r:(t._l=o={i:i=p(n,!0),k:n,v:r,p:e=t._l,n:void 0,r:!1},t._f||(t._f=o),e&&(e.n=o),t[d]++,"F"!==i&&(t._i[i]=o)),t},getEntry:y,setStrong:function(t,n,r){s(t,n,function(t,n){this._t=t,this._k=n,this._l=void 0},function(){for(var t=this,n=t._k,r=t._l;r&&r.r;)r=r.p;return t._t&&(t._l=r=r?r.n:t._t._f)?"keys"==n?l(0,r.k):"values"==n?l(0,r.v):l(0,[r.k,r.v]):(t._t=void 0,l(1))},r?"entries":"values",!r,!0),h(n)}}},function(t,n,r){var e=r(114),i=r(161);t.exports=function(t){return function(){if(e(this)!=t)throw TypeError(t+"#toJSON isn't generic");return i(this)}}},function(t,n,r){"use strict";var e=r(73),i=r(65).getWeak,o=r(2),u=r(6),c=r(68),f=r(79),a=r(48),s=r(24),l=a(5),h=a(6),v=0,p=function(t){return t._l||(t._l=new d)},d=function(){this.a=[]},y=function(t,n){return l(t.a,function(t){return t[0]===n})};d.prototype={get:function(t){var n=y(this,t);if(n)return n[1]},has:function(t){return!!y(this,t)},set:function(t,n){var r=y(this,t);r?r[1]=n:this.a.push([t,n])},delete:function(t){var n=h(this.a,function(n){return n[0]===t});return~n&&this.a.splice(n,1),!!~n}},t.exports={getConstructor:function(t,n,r,o){var a=t(function(t,e){c(t,a,n,"_i"),t._i=v++,t._l=void 0,void 0!=e&&f(e,r,t[o],t)});return e(a.prototype,{delete:function(t){if(!u(t))return!1;var n=i(t);return!0===n?p(this).delete(t):n&&s(n,this._i)&&delete n[this._i]},has:function(t){if(!u(t))return!1;var n=i(t);return!0===n?p(this).has(t):n&&s(n,this._i)}}),a},def:function(t,n,r){var e=i(o(n),!0);return!0===e?p(t).set(n,r):e[t._i]=r,t},ufstore:p}},function(t,n,r){t.exports=!r(10)&&!r(4)(function(){return 7!=Object.defineProperty(r(132)("div"),"a",{get:function(){return 7}}).a})},function(t,n,r){var e=r(6),i=Math.floor;t.exports=function(t){return!e(t)&&isFinite(t)&&i(t)===t}},function(t,n,r){var e=r(2);t.exports=function(t,n,r,i){try{return i?n(e(r)[0],r[1]):n(r)}catch(n){var o=t.return;throw void 0!==o&&e(o.call(t)),n}}},function(t,n){t.exports=function(t,n){return{value:n,done:!!t}}},function(t,n){t.exports=Math.log1p||function(t){return(t=+t)>-1e-8&&t<1e-8?t-t*t/2:Math.log(1+t)}},function(t,n,r){"use strict";var e=r(72),i=r(125),o=r(116),u=r(17),c=r(115),f=Object.assign;t.exports=!f||r(4)(function(){var t={},n={},r=Symbol(),e="abcdefghijklmnopqrst";return t[r]=7,e.split("").forEach(function(t){n[t]=t}),7!=f({},t)[r]||Object.keys(f({},n)).join("")!=e})?function(t,n){for(var r=u(t),f=arguments.length,a=1,s=i.f,l=o.f;f>a;)for(var h,v=c(arguments[a++]),p=s?e(v).concat(s(v)):e(v),d=p.length,y=0;d>y;)l.call(v,h=p[y++])&&(r[h]=v[h]);return r}:f},function(t,n,r){var e=r(11),i=r(2),o=r(72);t.exports=r(10)?Object.defineProperties:function(t,n){i(t);for(var r,u=o(n),c=u.length,f=0;c>f;)e.f(t,r=u[f++],n[r]);return t}},function(t,n,r){var e=r(30),i=r(71).f,o={}.toString,u="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[],c=function(t){try{return i(t)}catch(t){return u.slice()}};t.exports.f=function(t){return u&&"[object Window]"==o.call(t)?c(t):i(e(t))}},function(t,n,r){var e=r(24),i=r(30),o=r(117)(!1),u=r(145)("IE_PROTO");t.exports=function(t,n){var r,c=i(t),f=0,a=[];for(r in c)r!=u&&e(c,r)&&a.push(r);for(;n.length>f;)e(c,r=n[f++])&&(~o(a,r)||a.push(r));return a}},function(t,n,r){var e=r(72),i=r(30),o=r(116).f;t.exports=function(t){return function(n){for(var r,u=i(n),c=e(u),f=c.length,a=0,s=[];f>a;)o.call(u,r=c[a++])&&s.push(t?[r,u[r]]:u[r]);return s}}},function(t,n,r){var e=r(71),i=r(125),o=r(2),u=r(3).Reflect;t.exports=u&&u.ownKeys||function(t){var n=e.f(o(t)),r=i.f;return r?n.concat(r(t)):n}},function(t,n,r){var e=r(3).parseFloat,i=r(82).trim;t.exports=1/e(r(150)+"-0")!=-1/0?function(t){var n=i(String(t),3),r=e(n);return 0===r&&"-"==n.charAt(0)?-0:r}:e},function(t,n,r){var e=r(3).parseInt,i=r(82).trim,o=r(150),u=/^[\-+]?0[xX]/;t.exports=8!==e(o+"08")||22!==e(o+"0x16")?function(t,n){var r=i(String(t),3);return e(r,n>>>0||(u.test(r)?16:10))}:e},function(t,n){t.exports=Object.is||function(t,n){return t===n?0!==t||1/t==1/n:t!=t&&n!=n}},function(t,n,r){var e=r(16),i=r(149),o=r(46);t.exports=function(t,n,r,u){var c=String(o(t)),f=c.length,a=void 0===r?" ":String(r),s=e(n);if(s<=f||""==a)return c;var l=s-f,h=i.call(a,Math.ceil(l/a.length));return h.length>l&&(h=h.slice(0,l)),u?h+c:c+h}},function(t,n,r){n.f=r(7)},function(t,n,r){"use strict";var e=r(164);t.exports=r(118)("Map",function(t){return function(){return t(this,arguments.length>0?arguments[0]:void 0)}},{get:function(t){var n=e.getEntry(this,t);return n&&n.v},set:function(t,n){return e.def(this,0===t?0:t,n)}},e,!0)},function(t,n,r){r(10)&&"g"!=/./g.flags&&r(11).f(RegExp.prototype,"flags",{configurable:!0,get:r(120)})},function(t,n,r){"use strict";var e=r(164);t.exports=r(118)("Set",function(t){return function(){return t(this,arguments.length>0?arguments[0]:void 0)}},{add:function(t){return e.def(this,t=0===t?0:t,t)}},e)},function(t,n,r){"use strict";var e,i=r(48)(0),o=r(28),u=r(65),c=r(172),f=r(166),a=r(6),s=u.getWeak,l=Object.isExtensible,h=f.ufstore,v={},p=function(t){return function(){return t(this,arguments.length>0?arguments[0]:void 0)}},d={get:function(t){if(a(t)){var n=s(t);return!0===n?h(this).get(t):n?n[this._i]:void 0}},set:function(t,n){return f.def(this,t,n)}},y=t.exports=r(118)("WeakMap",p,d,f,!0,!0);7!=(new y).set((Object.freeze||Object)(v),7).get(v)&&(e=f.getConstructor(p),c(e.prototype,d),u.NEED=!0,i(["delete","has","get","set"],function(t){var n=y.prototype,r=n[t];o(n,t,function(n,i){if(a(n)&&!l(n)){this._f||(this._f=new e);var o=this._f[t](n,i);return"set"==t?this:o}return r.call(this,n,i)})}))},,,,function(t,n){"use strict";function r(){var t=document.querySelector("#page-nav");if(t&&!document.querySelector("#page-nav .extend.prev")&&(t.innerHTML='<a class="extend prev disabled" rel="prev">&laquo; Prev</a>'+t.innerHTML),t&&!document.querySelector("#page-nav .extend.next")&&(t.innerHTML=t.innerHTML+'<a class="extend next disabled" rel="next">Next &raquo;</a>'),yiliaConfig&&yiliaConfig.open_in_new){document.querySelectorAll(".article-entry a:not(.article-more-a)").forEach(function(t){var n=t.getAttribute("target");n&&""!==n||t.setAttribute("target","_blank")})}if(yiliaConfig&&yiliaConfig.toc_hide_index){document.querySelectorAll(".toc-number").forEach(function(t){t.style.display="none"})}var n=document.querySelector("#js-aboutme");n&&0!==n.length&&(n.innerHTML=n.innerText)}t.exports={init:r}},function(t,n,r){"use strict";function e(t){return t&&t.__esModule?t:{default:t}}function i(t,n){var r=/\/|index.html/g;return t.replace(r,"")===n.replace(r,"")}function o(){for(var t=document.querySelectorAll(".js-header-menu li a"),n=window.location.pathname,r=0,e=t.length;r<e;r++){var o=t[r];i(n,o.getAttribute("href"))&&(0,h.default)(o,"active")}}function u(t){for(var n=t.offsetLeft,r=t.offsetParent;null!==r;)n+=r.offsetLeft,r=r.offsetParent;return n}function c(t){for(var n=t.offsetTop,r=t.offsetParent;null!==r;)n+=r.offsetTop,r=r.offsetParent;return n}function f(t,n,r,e,i){var o=u(t),f=c(t)-n;if(f-r<=i){var a=t.$newDom;a||(a=t.cloneNode(!0),(0,d.default)(t,a),t.$newDom=a,a.style.position="fixed",a.style.top=(r||f)+"px",a.style.left=o+"px",a.style.zIndex=e||2,a.style.width="100%",a.style.color="#fff"),a.style.visibility="visible",t.style.visibility="hidden"}else{t.style.visibility="visible";var s=t.$newDom;s&&(s.style.visibility="hidden")}}function a(){var t=document.querySelector(".js-overlay"),n=document.querySelector(".js-header-menu");f(t,document.body.scrollTop,-63,2,0),f(n,document.body.scrollTop,1,3,0)}function s(){document.querySelector("#container").addEventListener("scroll",function(t){a()}),window.addEventListener("scroll",function(t){a()}),a()}var l=r(156),h=e(l),v=r(157),p=(e(v),r(382)),d=e(p),y=r(128),g=e(y),b=r(190),m=e(b),x=r(129);(function(){g.default.versions.mobile&&window.screen.width<800&&(o(),s())})(),(0,x.addLoadEvent)(function(){m.default.init()}),t.exports={}},,,,function(t,n,r){(function(t){"use strict";function n(t,n,r){t[n]||Object[e](t,n,{writable:!0,configurable:!0,value:r})}if(r(381),r(391),r(198),t._babelPolyfill)throw new Error("only one instance of babel-polyfill is allowed");t._babelPolyfill=!0;var e="defineProperty";n(String.prototype,"padLeft","".padStart),n(String.prototype,"padRight","".padEnd),"pop,reverse,shift,keys,values,entries,indexOf,every,some,forEach,map,filter,find,findIndex,includes,join,slice,concat,push,splice,unshift,sort,lastIndexOf,reduce,reduceRight,copyWithin,fill".split(",").forEach(function(t){[][t]&&n(Array,t,Function.call.bind([][t]))})}).call(n,function(){return this}())},,,function(t,n,r){r(210),t.exports=r(52).RegExp.escape},,,,function(t,n,r){var e=r(6),i=r(138),o=r(7)("species");t.exports=function(t){var n;return i(t)&&(n=t.constructor,"function"!=typeof n||n!==Array&&!i(n.prototype)||(n=void 0),e(n)&&null===(n=n[o])&&(n=void 0)),void 0===n?Array:n}},function(t,n,r){var e=r(202);t.exports=function(t,n){return new(e(t))(n)}},function(t,n,r){"use strict";var e=r(2),i=r(50),o="number";t.exports=function(t){if("string"!==t&&t!==o&&"default"!==t)throw TypeError("Incorrect hint");return i(e(this),t!=o)}},function(t,n,r){var e=r(72),i=r(125),o=r(116);t.exports=function(t){var n=e(t),r=i.f;if(r)for(var u,c=r(t),f=o.f,a=0;c.length>a;)f.call(t,u=c[a++])&&n.push(u);return n}},function(t,n,r){var e=r(72),i=r(30);t.exports=function(t,n){for(var r,o=i(t),u=e(o),c=u.length,f=0;c>f;)if(o[r=u[f++]]===n)return r}},function(t,n,r){"use strict";var e=r(208),i=r(121),o=r(26);t.exports=function(){for(var t=o(this),n=arguments.length,r=Array(n),u=0,c=e._,f=!1;n>u;)(r[u]=arguments[u++])===c&&(f=!0);return function(){var e,o=this,u=arguments.length,a=0,s=0;if(!f&&!u)return i(t,r,o);if(e=r.slice(),f)for(;n>a;a++)e[a]===c&&(e[a]=arguments[s++]);for(;u>s;)e.push(arguments[s++]);return i(t,e,o)}}},function(t,n,r){t.exports=r(3)},function(t,n){t.exports=function(t,n){var r=n===Object(n)?function(t){return n[t]}:n;return function(n){return String(n).replace(t,r)}}},function(t,n,r){var e=r(1),i=r(209)(/[\\^$*+?.()|[\]{}]/g,"\\$&");e(e.S,"RegExp",{escape:function(t){return i(t)}})},function(t,n,r){var e=r(1);e(e.P,"Array",{copyWithin:r(160)}),r(78)("copyWithin")},function(t,n,r){"use strict";var e=r(1),i=r(48)(4);e(e.P+e.F*!r(47)([].every,!0),"Array",{every:function(t){return i(this,t,arguments[1])}})},function(t,n,r){var e=r(1);e(e.P,"Array",{fill:r(130)}),r(78)("fill")},function(t,n,r){"use strict";var e=r(1),i=r(48)(2);e(e.P+e.F*!r(47)([].filter,!0),"Array",{filter:function(t){return i(this,t,arguments[1])}})},function(t,n,r){"use strict";var e=r(1),i=r(48)(6),o="findIndex",u=!0;o in[]&&Array(1)[o](function(){u=!1}),e(e.P+e.F*u,"Array",{findIndex:function(t){return i(this,t,arguments.length>1?arguments[1]:void 0)}}),r(78)(o)},function(t,n,r){"use strict";var e=r(1),i=r(48)(5),o="find",u=!0;o in[]&&Array(1)[o](function(){u=!1}),e(e.P+e.F*u,"Array",{find:function(t){return i(this,t,arguments.length>1?arguments[1]:void 0)}}),r(78)(o)},function(t,n,r){"use strict";var e=r(1),i=r(48)(0),o=r(47)([].forEach,!0);e(e.P+e.F*!o,"Array",{forEach:function(t){return i(this,t,arguments[1])}})},function(t,n,r){"use strict";var e=r(53),i=r(1),o=r(17),u=r(169),c=r(137),f=r(16),a=r(131),s=r(154);i(i.S+i.F*!r(123)(function(t){Array.from(t)}),"Array",{from:function(t){var n,r,i,l,h=o(t),v="function"==typeof this?this:Array,p=arguments.length,d=p>1?arguments[1]:void 0,y=void 0!==d,g=0,b=s(h);if(y&&(d=e(d,p>2?arguments[2]:void 0,2)),void 0==b||v==Array&&c(b))for(n=f(h.length),r=new v(n);n>g;g++)a(r,g,y?d(h[g],g):h[g]);else for(l=b.call(h),r=new v;!(i=l.next()).done;g++)a(r,g,y?u(l,d,[i.value,g],!0):i.value);return r.length=g,r}})},function(t,n,r){"use strict";var e=r(1),i=r(117)(!1),o=[].indexOf,u=!!o&&1/[1].indexOf(1,-0)<0;e(e.P+e.F*(u||!r(47)(o)),"Array",{indexOf:function(t){return u?o.apply(this,arguments)||0:i(this,t,arguments[1])}})},function(t,n,r){var e=r(1);e(e.S,"Array",{isArray:r(138)})},function(t,n,r){"use strict";var e=r(1),i=r(30),o=[].join;e(e.P+e.F*(r(115)!=Object||!r(47)(o)),"Array",{join:function(t){return o.call(i(this),void 0===t?",":t)}})},function(t,n,r){"use strict";var e=r(1),i=r(30),o=r(67),u=r(16),c=[].lastIndexOf,f=!!c&&1/[1].lastIndexOf(1,-0)<0;e(e.P+e.F*(f||!r(47)(c)),"Array",{lastIndexOf:function(t){if(f)return c.apply(this,arguments)||0;var n=i(this),r=u(n.length),e=r-1;for(arguments.length>1&&(e=Math.min(e,o(arguments[1]))),e<0&&(e=r+e);e>=0;e--)if(e in n&&n[e]===t)return e||0;return-1}})},function(t,n,r){"use strict";var e=r(1),i=r(48)(1);e(e.P+e.F*!r(47)([].map,!0),"Array",{map:function(t){return i(this,t,arguments[1])}})},function(t,n,r){"use strict";var e=r(1),i=r(131);e(e.S+e.F*r(4)(function(){function t(){}return!(Array.of.call(t)instanceof t)}),"Array",{of:function(){for(var t=0,n=arguments.length,r=new("function"==typeof this?this:Array)(n);n>t;)i(r,t,arguments[t++]);return r.length=n,r}})},function(t,n,r){"use strict";var e=r(1),i=r(162);e(e.P+e.F*!r(47)([].reduceRight,!0),"Array",{reduceRight:function(t){return i(this,t,arguments.length,arguments[1],!0)}})},function(t,n,r){"use strict";var e=r(1),i=r(162);e(e.P+e.F*!r(47)([].reduce,!0),"Array",{reduce:function(t){return i(this,t,arguments.length,arguments[1],!1)}})},function(t,n,r){"use strict";var e=r(1),i=r(135),o=r(45),u=r(75),c=r(16),f=[].slice;e(e.P+e.F*r(4)(function(){i&&f.call(i)}),"Array",{slice:function(t,n){var r=c(this.length),e=o(this);if(n=void 0===n?r:n,"Array"==e)return f.call(this,t,n);for(var i=u(t,r),a=u(n,r),s=c(a-i),l=Array(s),h=0;h<s;h++)l[h]="String"==e?this.charAt(i+h):this[i+h];return l}})},function(t,n,r){"use strict";var e=r(1),i=r(48)(3);e(e.P+e.F*!r(47)([].some,!0),"Array",{some:function(t){return i(this,t,arguments[1])}})},function(t,n,r){"use strict";var e=r(1),i=r(26),o=r(17),u=r(4),c=[].sort,f=[1,2,3];e(e.P+e.F*(u(function(){f.sort(void 0)})||!u(function(){f.sort(null)})||!r(47)(c)),"Array",{sort:function(t){return void 0===t?c.call(o(this)):c.call(o(this),i(t))}})},function(t,n,r){r(74)("Array")},function(t,n,r){var e=r(1);e(e.S,"Date",{now:function(){return(new Date).getTime()}})},function(t,n,r){"use strict";var e=r(1),i=r(4),o=Date.prototype.getTime,u=function(t){return t>9?t:"0"+t};e(e.P+e.F*(i(function(){return"0385-07-25T07:06:39.999Z"!=new Date(-5e13-1).toISOString()})||!i(function(){new Date(NaN).toISOString()})),"Date",{toISOString:function(){
if(!isFinite(o.call(this)))throw RangeError("Invalid time value");var t=this,n=t.getUTCFullYear(),r=t.getUTCMilliseconds(),e=n<0?"-":n>9999?"+":"";return e+("00000"+Math.abs(n)).slice(e?-6:-4)+"-"+u(t.getUTCMonth()+1)+"-"+u(t.getUTCDate())+"T"+u(t.getUTCHours())+":"+u(t.getUTCMinutes())+":"+u(t.getUTCSeconds())+"."+(r>99?r:"0"+u(r))+"Z"}})},function(t,n,r){"use strict";var e=r(1),i=r(17),o=r(50);e(e.P+e.F*r(4)(function(){return null!==new Date(NaN).toJSON()||1!==Date.prototype.toJSON.call({toISOString:function(){return 1}})}),"Date",{toJSON:function(t){var n=i(this),r=o(n);return"number"!=typeof r||isFinite(r)?n.toISOString():null}})},function(t,n,r){var e=r(7)("toPrimitive"),i=Date.prototype;e in i||r(27)(i,e,r(204))},function(t,n,r){var e=Date.prototype,i="Invalid Date",o="toString",u=e[o],c=e.getTime;new Date(NaN)+""!=i&&r(28)(e,o,function(){var t=c.call(this);return t===t?u.call(this):i})},function(t,n,r){var e=r(1);e(e.P,"Function",{bind:r(163)})},function(t,n,r){"use strict";var e=r(6),i=r(32),o=r(7)("hasInstance"),u=Function.prototype;o in u||r(11).f(u,o,{value:function(t){if("function"!=typeof this||!e(t))return!1;if(!e(this.prototype))return t instanceof this;for(;t=i(t);)if(this.prototype===t)return!0;return!1}})},function(t,n,r){var e=r(11).f,i=r(66),o=r(24),u=Function.prototype,c="name",f=Object.isExtensible||function(){return!0};c in u||r(10)&&e(u,c,{configurable:!0,get:function(){try{var t=this,n=(""+t).match(/^\s*function ([^ (]*)/)[1];return o(t,c)||!f(t)||e(t,c,i(5,n)),n}catch(t){return""}}})},function(t,n,r){var e=r(1),i=r(171),o=Math.sqrt,u=Math.acosh;e(e.S+e.F*!(u&&710==Math.floor(u(Number.MAX_VALUE))&&u(1/0)==1/0),"Math",{acosh:function(t){return(t=+t)<1?NaN:t>94906265.62425156?Math.log(t)+Math.LN2:i(t-1+o(t-1)*o(t+1))}})},function(t,n,r){function e(t){return isFinite(t=+t)&&0!=t?t<0?-e(-t):Math.log(t+Math.sqrt(t*t+1)):t}var i=r(1),o=Math.asinh;i(i.S+i.F*!(o&&1/o(0)>0),"Math",{asinh:e})},function(t,n,r){var e=r(1),i=Math.atanh;e(e.S+e.F*!(i&&1/i(-0)<0),"Math",{atanh:function(t){return 0==(t=+t)?t:Math.log((1+t)/(1-t))/2}})},function(t,n,r){var e=r(1),i=r(142);e(e.S,"Math",{cbrt:function(t){return i(t=+t)*Math.pow(Math.abs(t),1/3)}})},function(t,n,r){var e=r(1);e(e.S,"Math",{clz32:function(t){return(t>>>=0)?31-Math.floor(Math.log(t+.5)*Math.LOG2E):32}})},function(t,n,r){var e=r(1),i=Math.exp;e(e.S,"Math",{cosh:function(t){return(i(t=+t)+i(-t))/2}})},function(t,n,r){var e=r(1),i=r(141);e(e.S+e.F*(i!=Math.expm1),"Math",{expm1:i})},function(t,n,r){var e=r(1),i=r(142),o=Math.pow,u=o(2,-52),c=o(2,-23),f=o(2,127)*(2-c),a=o(2,-126),s=function(t){return t+1/u-1/u};e(e.S,"Math",{fround:function(t){var n,r,e=Math.abs(t),o=i(t);return e<a?o*s(e/a/c)*a*c:(n=(1+c/u)*e,r=n-(n-e),r>f||r!=r?o*(1/0):o*r)}})},function(t,n,r){var e=r(1),i=Math.abs;e(e.S,"Math",{hypot:function(t,n){for(var r,e,o=0,u=0,c=arguments.length,f=0;u<c;)r=i(arguments[u++]),f<r?(e=f/r,o=o*e*e+1,f=r):r>0?(e=r/f,o+=e*e):o+=r;return f===1/0?1/0:f*Math.sqrt(o)}})},function(t,n,r){var e=r(1),i=Math.imul;e(e.S+e.F*r(4)(function(){return-5!=i(4294967295,5)||2!=i.length}),"Math",{imul:function(t,n){var r=65535,e=+t,i=+n,o=r&e,u=r&i;return 0|o*u+((r&e>>>16)*u+o*(r&i>>>16)<<16>>>0)}})},function(t,n,r){var e=r(1);e(e.S,"Math",{log10:function(t){return Math.log(t)/Math.LN10}})},function(t,n,r){var e=r(1);e(e.S,"Math",{log1p:r(171)})},function(t,n,r){var e=r(1);e(e.S,"Math",{log2:function(t){return Math.log(t)/Math.LN2}})},function(t,n,r){var e=r(1);e(e.S,"Math",{sign:r(142)})},function(t,n,r){var e=r(1),i=r(141),o=Math.exp;e(e.S+e.F*r(4)(function(){return-2e-17!=!Math.sinh(-2e-17)}),"Math",{sinh:function(t){return Math.abs(t=+t)<1?(i(t)-i(-t))/2:(o(t-1)-o(-t-1))*(Math.E/2)}})},function(t,n,r){var e=r(1),i=r(141),o=Math.exp;e(e.S,"Math",{tanh:function(t){var n=i(t=+t),r=i(-t);return n==1/0?1:r==1/0?-1:(n-r)/(o(t)+o(-t))}})},function(t,n,r){var e=r(1);e(e.S,"Math",{trunc:function(t){return(t>0?Math.floor:Math.ceil)(t)}})},function(t,n,r){"use strict";var e=r(3),i=r(24),o=r(45),u=r(136),c=r(50),f=r(4),a=r(71).f,s=r(31).f,l=r(11).f,h=r(82).trim,v="Number",p=e[v],d=p,y=p.prototype,g=o(r(70)(y))==v,b="trim"in String.prototype,m=function(t){var n=c(t,!1);if("string"==typeof n&&n.length>2){n=b?n.trim():h(n,3);var r,e,i,o=n.charCodeAt(0);if(43===o||45===o){if(88===(r=n.charCodeAt(2))||120===r)return NaN}else if(48===o){switch(n.charCodeAt(1)){case 66:case 98:e=2,i=49;break;case 79:case 111:e=8,i=55;break;default:return+n}for(var u,f=n.slice(2),a=0,s=f.length;a<s;a++)if((u=f.charCodeAt(a))<48||u>i)return NaN;return parseInt(f,e)}}return+n};if(!p(" 0o1")||!p("0b1")||p("+0x1")){p=function(t){var n=arguments.length<1?0:t,r=this;return r instanceof p&&(g?f(function(){y.valueOf.call(r)}):o(r)!=v)?u(new d(m(n)),r,p):m(n)};for(var x,w=r(10)?a(d):"MAX_VALUE,MIN_VALUE,NaN,NEGATIVE_INFINITY,POSITIVE_INFINITY,EPSILON,isFinite,isInteger,isNaN,isSafeInteger,MAX_SAFE_INTEGER,MIN_SAFE_INTEGER,parseFloat,parseInt,isInteger".split(","),S=0;w.length>S;S++)i(d,x=w[S])&&!i(p,x)&&l(p,x,s(d,x));p.prototype=y,y.constructor=p,r(28)(e,v,p)}},function(t,n,r){var e=r(1);e(e.S,"Number",{EPSILON:Math.pow(2,-52)})},function(t,n,r){var e=r(1),i=r(3).isFinite;e(e.S,"Number",{isFinite:function(t){return"number"==typeof t&&i(t)}})},function(t,n,r){var e=r(1);e(e.S,"Number",{isInteger:r(168)})},function(t,n,r){var e=r(1);e(e.S,"Number",{isNaN:function(t){return t!=t}})},function(t,n,r){var e=r(1),i=r(168),o=Math.abs;e(e.S,"Number",{isSafeInteger:function(t){return i(t)&&o(t)<=9007199254740991}})},function(t,n,r){var e=r(1);e(e.S,"Number",{MAX_SAFE_INTEGER:9007199254740991})},function(t,n,r){var e=r(1);e(e.S,"Number",{MIN_SAFE_INTEGER:-9007199254740991})},function(t,n,r){var e=r(1),i=r(178);e(e.S+e.F*(Number.parseFloat!=i),"Number",{parseFloat:i})},function(t,n,r){var e=r(1),i=r(179);e(e.S+e.F*(Number.parseInt!=i),"Number",{parseInt:i})},function(t,n,r){"use strict";var e=r(1),i=r(67),o=r(159),u=r(149),c=1..toFixed,f=Math.floor,a=[0,0,0,0,0,0],s="Number.toFixed: incorrect invocation!",l="0",h=function(t,n){for(var r=-1,e=n;++r<6;)e+=t*a[r],a[r]=e%1e7,e=f(e/1e7)},v=function(t){for(var n=6,r=0;--n>=0;)r+=a[n],a[n]=f(r/t),r=r%t*1e7},p=function(){for(var t=6,n="";--t>=0;)if(""!==n||0===t||0!==a[t]){var r=String(a[t]);n=""===n?r:n+u.call(l,7-r.length)+r}return n},d=function(t,n,r){return 0===n?r:n%2==1?d(t,n-1,r*t):d(t*t,n/2,r)},y=function(t){for(var n=0,r=t;r>=4096;)n+=12,r/=4096;for(;r>=2;)n+=1,r/=2;return n};e(e.P+e.F*(!!c&&("0.000"!==8e-5.toFixed(3)||"1"!==.9.toFixed(0)||"1.25"!==1.255.toFixed(2)||"1000000000000000128"!==(0xde0b6b3a7640080).toFixed(0))||!r(4)(function(){c.call({})})),"Number",{toFixed:function(t){var n,r,e,c,f=o(this,s),a=i(t),g="",b=l;if(a<0||a>20)throw RangeError(s);if(f!=f)return"NaN";if(f<=-1e21||f>=1e21)return String(f);if(f<0&&(g="-",f=-f),f>1e-21)if(n=y(f*d(2,69,1))-69,r=n<0?f*d(2,-n,1):f/d(2,n,1),r*=4503599627370496,(n=52-n)>0){for(h(0,r),e=a;e>=7;)h(1e7,0),e-=7;for(h(d(10,e,1),0),e=n-1;e>=23;)v(1<<23),e-=23;v(1<<e),h(1,1),v(2),b=p()}else h(0,r),h(1<<-n,0),b=p()+u.call(l,a);return a>0?(c=b.length,b=g+(c<=a?"0."+u.call(l,a-c)+b:b.slice(0,c-a)+"."+b.slice(c-a))):b=g+b,b}})},function(t,n,r){"use strict";var e=r(1),i=r(4),o=r(159),u=1..toPrecision;e(e.P+e.F*(i(function(){return"1"!==u.call(1,void 0)})||!i(function(){u.call({})})),"Number",{toPrecision:function(t){var n=o(this,"Number#toPrecision: incorrect invocation!");return void 0===t?u.call(n):u.call(n,t)}})},function(t,n,r){var e=r(1);e(e.S+e.F,"Object",{assign:r(172)})},function(t,n,r){var e=r(1);e(e.S,"Object",{create:r(70)})},function(t,n,r){var e=r(1);e(e.S+e.F*!r(10),"Object",{defineProperties:r(173)})},function(t,n,r){var e=r(1);e(e.S+e.F*!r(10),"Object",{defineProperty:r(11).f})},function(t,n,r){var e=r(6),i=r(65).onFreeze;r(49)("freeze",function(t){return function(n){return t&&e(n)?t(i(n)):n}})},function(t,n,r){var e=r(30),i=r(31).f;r(49)("getOwnPropertyDescriptor",function(){return function(t,n){return i(e(t),n)}})},function(t,n,r){r(49)("getOwnPropertyNames",function(){return r(174).f})},function(t,n,r){var e=r(17),i=r(32);r(49)("getPrototypeOf",function(){return function(t){return i(e(t))}})},function(t,n,r){var e=r(6);r(49)("isExtensible",function(t){return function(n){return!!e(n)&&(!t||t(n))}})},function(t,n,r){var e=r(6);r(49)("isFrozen",function(t){return function(n){return!e(n)||!!t&&t(n)}})},function(t,n,r){var e=r(6);r(49)("isSealed",function(t){return function(n){return!e(n)||!!t&&t(n)}})},function(t,n,r){var e=r(1);e(e.S,"Object",{is:r(180)})},function(t,n,r){var e=r(17),i=r(72);r(49)("keys",function(){return function(t){return i(e(t))}})},function(t,n,r){var e=r(6),i=r(65).onFreeze;r(49)("preventExtensions",function(t){return function(n){return t&&e(n)?t(i(n)):n}})},function(t,n,r){var e=r(6),i=r(65).onFreeze;r(49)("seal",function(t){return function(n){return t&&e(n)?t(i(n)):n}})},function(t,n,r){var e=r(1);e(e.S,"Object",{setPrototypeOf:r(144).set})},function(t,n,r){"use strict";var e=r(114),i={};i[r(7)("toStringTag")]="z",i+""!="[object z]"&&r(28)(Object.prototype,"toString",function(){return"[object "+e(this)+"]"},!0)},function(t,n,r){var e=r(1),i=r(178);e(e.G+e.F*(parseFloat!=i),{parseFloat:i})},function(t,n,r){var e=r(1),i=r(179);e(e.G+e.F*(parseInt!=i),{parseInt:i})},function(t,n,r){"use strict";var e,i,o,u=r(69),c=r(3),f=r(53),a=r(114),s=r(1),l=r(6),h=r(26),v=r(68),p=r(79),d=r(146),y=r(151).set,g=r(143)(),b="Promise",m=c.TypeError,x=c.process,w=c[b],x=c.process,S="process"==a(x),_=function(){},O=!!function(){try{var t=w.resolve(1),n=(t.constructor={})[r(7)("species")]=function(t){t(_,_)};return(S||"function"==typeof PromiseRejectionEvent)&&t.then(_)instanceof n}catch(t){}}(),E=function(t,n){return t===n||t===w&&n===o},P=function(t){var n;return!(!l(t)||"function"!=typeof(n=t.then))&&n},j=function(t){return E(w,t)?new F(t):new i(t)},F=i=function(t){var n,r;this.promise=new t(function(t,e){if(void 0!==n||void 0!==r)throw m("Bad Promise constructor");n=t,r=e}),this.resolve=h(n),this.reject=h(r)},M=function(t){try{t()}catch(t){return{error:t}}},A=function(t,n){if(!t._n){t._n=!0;var r=t._c;g(function(){for(var e=t._v,i=1==t._s,o=0;r.length>o;)!function(n){var r,o,u=i?n.ok:n.fail,c=n.resolve,f=n.reject,a=n.domain;try{u?(i||(2==t._h&&I(t),t._h=1),!0===u?r=e:(a&&a.enter(),r=u(e),a&&a.exit()),r===n.promise?f(m("Promise-chain cycle")):(o=P(r))?o.call(r,c,f):c(r)):f(e)}catch(t){f(t)}}(r[o++]);t._c=[],t._n=!1,n&&!t._h&&N(t)})}},N=function(t){y.call(c,function(){var n,r,e,i=t._v;if(T(t)&&(n=M(function(){S?x.emit("unhandledRejection",i,t):(r=c.onunhandledrejection)?r({promise:t,reason:i}):(e=c.console)&&e.error&&e.error("Unhandled promise rejection",i)}),t._h=S||T(t)?2:1),t._a=void 0,n)throw n.error})},T=function(t){if(1==t._h)return!1;for(var n,r=t._a||t._c,e=0;r.length>e;)if(n=r[e++],n.fail||!T(n.promise))return!1;return!0},I=function(t){y.call(c,function(){var n;S?x.emit("rejectionHandled",t):(n=c.onrejectionhandled)&&n({promise:t,reason:t._v})})},k=function(t){var n=this;n._d||(n._d=!0,n=n._w||n,n._v=t,n._s=2,n._a||(n._a=n._c.slice()),A(n,!0))},L=function(t){var n,r=this;if(!r._d){r._d=!0,r=r._w||r;try{if(r===t)throw m("Promise can't be resolved itself");(n=P(t))?g(function(){var e={_w:r,_d:!1};try{n.call(t,f(L,e,1),f(k,e,1))}catch(t){k.call(e,t)}}):(r._v=t,r._s=1,A(r,!1))}catch(t){k.call({_w:r,_d:!1},t)}}};O||(w=function(t){v(this,w,b,"_h"),h(t),e.call(this);try{t(f(L,this,1),f(k,this,1))}catch(t){k.call(this,t)}},e=function(t){this._c=[],this._a=void 0,this._s=0,this._d=!1,this._v=void 0,this._h=0,this._n=!1},e.prototype=r(73)(w.prototype,{then:function(t,n){var r=j(d(this,w));return r.ok="function"!=typeof t||t,r.fail="function"==typeof n&&n,r.domain=S?x.domain:void 0,this._c.push(r),this._a&&this._a.push(r),this._s&&A(this,!1),r.promise},catch:function(t){return this.then(void 0,t)}}),F=function(){var t=new e;this.promise=t,this.resolve=f(L,t,1),this.reject=f(k,t,1)}),s(s.G+s.W+s.F*!O,{Promise:w}),r(81)(w,b),r(74)(b),o=r(52)[b],s(s.S+s.F*!O,b,{reject:function(t){var n=j(this);return(0,n.reject)(t),n.promise}}),s(s.S+s.F*(u||!O),b,{resolve:function(t){if(t instanceof w&&E(t.constructor,this))return t;var n=j(this);return(0,n.resolve)(t),n.promise}}),s(s.S+s.F*!(O&&r(123)(function(t){w.all(t).catch(_)})),b,{all:function(t){var n=this,r=j(n),e=r.resolve,i=r.reject,o=M(function(){var r=[],o=0,u=1;p(t,!1,function(t){var c=o++,f=!1;r.push(void 0),u++,n.resolve(t).then(function(t){f||(f=!0,r[c]=t,--u||e(r))},i)}),--u||e(r)});return o&&i(o.error),r.promise},race:function(t){var n=this,r=j(n),e=r.reject,i=M(function(){p(t,!1,function(t){n.resolve(t).then(r.resolve,e)})});return i&&e(i.error),r.promise}})},function(t,n,r){var e=r(1),i=r(26),o=r(2),u=(r(3).Reflect||{}).apply,c=Function.apply;e(e.S+e.F*!r(4)(function(){u(function(){})}),"Reflect",{apply:function(t,n,r){var e=i(t),f=o(r);return u?u(e,n,f):c.call(e,n,f)}})},function(t,n,r){var e=r(1),i=r(70),o=r(26),u=r(2),c=r(6),f=r(4),a=r(163),s=(r(3).Reflect||{}).construct,l=f(function(){function t(){}return!(s(function(){},[],t)instanceof t)}),h=!f(function(){s(function(){})});e(e.S+e.F*(l||h),"Reflect",{construct:function(t,n){o(t),u(n);var r=arguments.length<3?t:o(arguments[2]);if(h&&!l)return s(t,n,r);if(t==r){switch(n.length){case 0:return new t;case 1:return new t(n[0]);case 2:return new t(n[0],n[1]);case 3:return new t(n[0],n[1],n[2]);case 4:return new t(n[0],n[1],n[2],n[3])}var e=[null];return e.push.apply(e,n),new(a.apply(t,e))}var f=r.prototype,v=i(c(f)?f:Object.prototype),p=Function.apply.call(t,v,n);return c(p)?p:v}})},function(t,n,r){var e=r(11),i=r(1),o=r(2),u=r(50);i(i.S+i.F*r(4)(function(){Reflect.defineProperty(e.f({},1,{value:1}),1,{value:2})}),"Reflect",{defineProperty:function(t,n,r){o(t),n=u(n,!0),o(r);try{return e.f(t,n,r),!0}catch(t){return!1}}})},function(t,n,r){var e=r(1),i=r(31).f,o=r(2);e(e.S,"Reflect",{deleteProperty:function(t,n){var r=i(o(t),n);return!(r&&!r.configurable)&&delete t[n]}})},function(t,n,r){"use strict";var e=r(1),i=r(2),o=function(t){this._t=i(t),this._i=0;var n,r=this._k=[];for(n in t)r.push(n)};r(139)(o,"Object",function(){var t,n=this,r=n._k;do{if(n._i>=r.length)return{value:void 0,done:!0}}while(!((t=r[n._i++])in n._t));return{value:t,done:!1}}),e(e.S,"Reflect",{enumerate:function(t){return new o(t)}})},function(t,n,r){var e=r(31),i=r(1),o=r(2);i(i.S,"Reflect",{getOwnPropertyDescriptor:function(t,n){return e.f(o(t),n)}})},function(t,n,r){var e=r(1),i=r(32),o=r(2);e(e.S,"Reflect",{getPrototypeOf:function(t){return i(o(t))}})},function(t,n,r){function e(t,n){var r,c,s=arguments.length<3?t:arguments[2];return a(t)===s?t[n]:(r=i.f(t,n))?u(r,"value")?r.value:void 0!==r.get?r.get.call(s):void 0:f(c=o(t))?e(c,n,s):void 0}var i=r(31),o=r(32),u=r(24),c=r(1),f=r(6),a=r(2);c(c.S,"Reflect",{get:e})},function(t,n,r){var e=r(1);e(e.S,"Reflect",{has:function(t,n){return n in t}})},function(t,n,r){var e=r(1),i=r(2),o=Object.isExtensible;e(e.S,"Reflect",{isExtensible:function(t){return i(t),!o||o(t)}})},function(t,n,r){var e=r(1);e(e.S,"Reflect",{ownKeys:r(177)})},function(t,n,r){var e=r(1),i=r(2),o=Object.preventExtensions;e(e.S,"Reflect",{preventExtensions:function(t){i(t);try{return o&&o(t),!0}catch(t){return!1}}})},function(t,n,r){var e=r(1),i=r(144);i&&e(e.S,"Reflect",{setPrototypeOf:function(t,n){i.check(t,n);try{return i.set(t,n),!0}catch(t){return!1}}})},function(t,n,r){function e(t,n,r){var f,h,v=arguments.length<4?t:arguments[3],p=o.f(s(t),n);if(!p){if(l(h=u(t)))return e(h,n,r,v);p=a(0)}return c(p,"value")?!(!1===p.writable||!l(v)||(f=o.f(v,n)||a(0),f.value=r,i.f(v,n,f),0)):void 0!==p.set&&(p.set.call(v,r),!0)}var i=r(11),o=r(31),u=r(32),c=r(24),f=r(1),a=r(66),s=r(2),l=r(6);f(f.S,"Reflect",{set:e})},function(t,n,r){var e=r(3),i=r(136),o=r(11).f,u=r(71).f,c=r(122),f=r(120),a=e.RegExp,s=a,l=a.prototype,h=/a/g,v=/a/g,p=new a(h)!==h;if(r(10)&&(!p||r(4)(function(){return v[r(7)("match")]=!1,a(h)!=h||a(v)==v||"/a/i"!=a(h,"i")}))){a=function(t,n){var r=this instanceof a,e=c(t),o=void 0===n;return!r&&e&&t.constructor===a&&o?t:i(p?new s(e&&!o?t.source:t,n):s((e=t instanceof a)?t.source:t,e&&o?f.call(t):n),r?this:l,a)};for(var d=u(s),y=0;d.length>y;)!function(t){t in a||o(a,t,{configurable:!0,get:function(){return s[t]},set:function(n){s[t]=n}})}(d[y++]);l.constructor=a,a.prototype=l,r(28)(e,"RegExp",a)}r(74)("RegExp")},function(t,n,r){r(119)("match",1,function(t,n,r){return[function(r){"use strict";var e=t(this),i=void 0==r?void 0:r[n];return void 0!==i?i.call(r,e):new RegExp(r)[n](String(e))},r]})},function(t,n,r){r(119)("replace",2,function(t,n,r){return[function(e,i){"use strict";var o=t(this),u=void 0==e?void 0:e[n];return void 0!==u?u.call(e,o,i):r.call(String(o),e,i)},r]})},function(t,n,r){r(119)("search",1,function(t,n,r){return[function(r){"use strict";var e=t(this),i=void 0==r?void 0:r[n];return void 0!==i?i.call(r,e):new RegExp(r)[n](String(e))},r]})},function(t,n,r){r(119)("split",2,function(t,n,e){"use strict";var i=r(122),o=e,u=[].push,c="split",f="length",a="lastIndex";if("c"=="abbc"[c](/(b)*/)[1]||4!="test"[c](/(?:)/,-1)[f]||2!="ab"[c](/(?:ab)*/)[f]||4!="."[c](/(.?)(.?)/)[f]||"."[c](/()()/)[f]>1||""[c](/.?/)[f]){var s=void 0===/()??/.exec("")[1];e=function(t,n){var r=String(this);if(void 0===t&&0===n)return[];if(!i(t))return o.call(r,t,n);var e,c,l,h,v,p=[],d=(t.ignoreCase?"i":"")+(t.multiline?"m":"")+(t.unicode?"u":"")+(t.sticky?"y":""),y=0,g=void 0===n?4294967295:n>>>0,b=new RegExp(t.source,d+"g");for(s||(e=new RegExp("^"+b.source+"$(?!\\s)",d));(c=b.exec(r))&&!((l=c.index+c[0][f])>y&&(p.push(r.slice(y,c.index)),!s&&c[f]>1&&c[0].replace(e,function(){for(v=1;v<arguments[f]-2;v++)void 0===arguments[v]&&(c[v]=void 0)}),c[f]>1&&c.index<r[f]&&u.apply(p,c.slice(1)),h=c[0][f],y=l,p[f]>=g));)b[a]===c.index&&b[a]++;return y===r[f]?!h&&b.test("")||p.push(""):p.push(r.slice(y)),p[f]>g?p.slice(0,g):p}}else"0"[c](void 0,0)[f]&&(e=function(t,n){return void 0===t&&0===n?[]:o.call(this,t,n)});return[function(r,i){var o=t(this),u=void 0==r?void 0:r[n];return void 0!==u?u.call(r,o,i):e.call(String(o),r,i)},e]})},function(t,n,r){"use strict";r(184);var e=r(2),i=r(120),o=r(10),u="toString",c=/./[u],f=function(t){r(28)(RegExp.prototype,u,t,!0)};r(4)(function(){return"/a/b"!=c.call({source:"a",flags:"b"})})?f(function(){var t=e(this);return"/".concat(t.source,"/","flags"in t?t.flags:!o&&t instanceof RegExp?i.call(t):void 0)}):c.name!=u&&f(function(){return c.call(this)})},function(t,n,r){"use strict";r(29)("anchor",function(t){return function(n){return t(this,"a","name",n)}})},function(t,n,r){"use strict";r(29)("big",function(t){return function(){return t(this,"big","","")}})},function(t,n,r){"use strict";r(29)("blink",function(t){return function(){return t(this,"blink","","")}})},function(t,n,r){"use strict";r(29)("bold",function(t){return function(){return t(this,"b","","")}})},function(t,n,r){"use strict";var e=r(1),i=r(147)(!1);e(e.P,"String",{codePointAt:function(t){return i(this,t)}})},function(t,n,r){"use strict";var e=r(1),i=r(16),o=r(148),u="endsWith",c=""[u];e(e.P+e.F*r(134)(u),"String",{endsWith:function(t){var n=o(this,t,u),r=arguments.length>1?arguments[1]:void 0,e=i(n.length),f=void 0===r?e:Math.min(i(r),e),a=String(t);return c?c.call(n,a,f):n.slice(f-a.length,f)===a}})},function(t,n,r){"use strict";r(29)("fixed",function(t){return function(){return t(this,"tt","","")}})},function(t,n,r){"use strict";r(29)("fontcolor",function(t){return function(n){return t(this,"font","color",n)}})},function(t,n,r){"use strict";r(29)("fontsize",function(t){return function(n){return t(this,"font","size",n)}})},function(t,n,r){var e=r(1),i=r(75),o=String.fromCharCode,u=String.fromCodePoint;e(e.S+e.F*(!!u&&1!=u.length),"String",{fromCodePoint:function(t){for(var n,r=[],e=arguments.length,u=0;e>u;){if(n=+arguments[u++],i(n,1114111)!==n)throw RangeError(n+" is not a valid code point");r.push(n<65536?o(n):o(55296+((n-=65536)>>10),n%1024+56320))}return r.join("")}})},function(t,n,r){"use strict";var e=r(1),i=r(148),o="includes";e(e.P+e.F*r(134)(o),"String",{includes:function(t){return!!~i(this,t,o).indexOf(t,arguments.length>1?arguments[1]:void 0)}})},function(t,n,r){"use strict";r(29)("italics",function(t){return function(){return t(this,"i","","")}})},function(t,n,r){"use strict";var e=r(147)(!0);r(140)(String,"String",function(t){this._t=String(t),this._i=0},function(){var t,n=this._t,r=this._i;return r>=n.length?{value:void 0,done:!0}:(t=e(n,r),this._i+=t.length,{value:t,done:!1})})},function(t,n,r){"use strict";r(29)("link",function(t){return function(n){return t(this,"a","href",n)}})},function(t,n,r){var e=r(1),i=r(30),o=r(16);e(e.S,"String",{raw:function(t){for(var n=i(t.raw),r=o(n.length),e=arguments.length,u=[],c=0;r>c;)u.push(String(n[c++])),c<e&&u.push(String(arguments[c]));return u.join("")}})},function(t,n,r){var e=r(1);e(e.P,"String",{repeat:r(149)})},function(t,n,r){"use strict";r(29)("small",function(t){return function(){return t(this,"small","","")}})},function(t,n,r){"use strict";var e=r(1),i=r(16),o=r(148),u="startsWith",c=""[u];e(e.P+e.F*r(134)(u),"String",{startsWith:function(t){var n=o(this,t,u),r=i(Math.min(arguments.length>1?arguments[1]:void 0,n.length)),e=String(t);return c?c.call(n,e,r):n.slice(r,r+e.length)===e}})},function(t,n,r){"use strict";r(29)("strike",function(t){return function(){return t(this,"strike","","")}})},function(t,n,r){"use strict";r(29)("sub",function(t){return function(){return t(this,"sub","","")}})},function(t,n,r){"use strict";r(29)("sup",function(t){return function(){return t(this,"sup","","")}})},function(t,n,r){"use strict";r(82)("trim",function(t){return function(){return t(this,3)}})},function(t,n,r){"use strict";var e=r(3),i=r(24),o=r(10),u=r(1),c=r(28),f=r(65).KEY,a=r(4),s=r(126),l=r(81),h=r(76),v=r(7),p=r(182),d=r(153),y=r(206),g=r(205),b=r(138),m=r(2),x=r(30),w=r(50),S=r(66),_=r(70),O=r(174),E=r(31),P=r(11),j=r(72),F=E.f,M=P.f,A=O.f,N=e.Symbol,T=e.JSON,I=T&&T.stringify,k="prototype",L=v("_hidden"),R=v("toPrimitive"),C={}.propertyIsEnumerable,D=s("symbol-registry"),U=s("symbols"),W=s("op-symbols"),G=Object[k],B="function"==typeof N,V=e.QObject,z=!V||!V[k]||!V[k].findChild,q=o&&a(function(){return 7!=_(M({},"a",{get:function(){return M(this,"a",{value:7}).a}})).a})?function(t,n,r){var e=F(G,n);e&&delete G[n],M(t,n,r),e&&t!==G&&M(G,n,e)}:M,K=function(t){var n=U[t]=_(N[k]);return n._k=t,n},J=B&&"symbol"==typeof N.iterator?function(t){return"symbol"==typeof t}:function(t){return t instanceof N},Y=function(t,n,r){return t===G&&Y(W,n,r),m(t),n=w(n,!0),m(r),i(U,n)?(r.enumerable?(i(t,L)&&t[L][n]&&(t[L][n]=!1),r=_(r,{enumerable:S(0,!1)})):(i(t,L)||M(t,L,S(1,{})),t[L][n]=!0),q(t,n,r)):M(t,n,r)},H=function(t,n){m(t);for(var r,e=g(n=x(n)),i=0,o=e.length;o>i;)Y(t,r=e[i++],n[r]);return t},$=function(t,n){return void 0===n?_(t):H(_(t),n)},X=function(t){var n=C.call(this,t=w(t,!0));return!(this===G&&i(U,t)&&!i(W,t))&&(!(n||!i(this,t)||!i(U,t)||i(this,L)&&this[L][t])||n)},Q=function(t,n){if(t=x(t),n=w(n,!0),t!==G||!i(U,n)||i(W,n)){var r=F(t,n);return!r||!i(U,n)||i(t,L)&&t[L][n]||(r.enumerable=!0),r}},Z=function(t){for(var n,r=A(x(t)),e=[],o=0;r.length>o;)i(U,n=r[o++])||n==L||n==f||e.push(n);return e},tt=function(t){for(var n,r=t===G,e=A(r?W:x(t)),o=[],u=0;e.length>u;)!i(U,n=e[u++])||r&&!i(G,n)||o.push(U[n]);return o};B||(N=function(){if(this instanceof N)throw TypeError("Symbol is not a constructor!");var t=h(arguments.length>0?arguments[0]:void 0),n=function(r){this===G&&n.call(W,r),i(this,L)&&i(this[L],t)&&(this[L][t]=!1),q(this,t,S(1,r))};return o&&z&&q(G,t,{configurable:!0,set:n}),K(t)},c(N[k],"toString",function(){return this._k}),E.f=Q,P.f=Y,r(71).f=O.f=Z,r(116).f=X,r(125).f=tt,o&&!r(69)&&c(G,"propertyIsEnumerable",X,!0),p.f=function(t){return K(v(t))}),u(u.G+u.W+u.F*!B,{Symbol:N});for(var nt="hasInstance,isConcatSpreadable,iterator,match,replace,search,species,split,toPrimitive,toStringTag,unscopables".split(","),rt=0;nt.length>rt;)v(nt[rt++]);for(var nt=j(v.store),rt=0;nt.length>rt;)d(nt[rt++]);u(u.S+u.F*!B,"Symbol",{for:function(t){return i(D,t+="")?D[t]:D[t]=N(t)},keyFor:function(t){if(J(t))return y(D,t);throw TypeError(t+" is not a symbol!")},useSetter:function(){z=!0},useSimple:function(){z=!1}}),u(u.S+u.F*!B,"Object",{create:$,defineProperty:Y,defineProperties:H,getOwnPropertyDescriptor:Q,getOwnPropertyNames:Z,getOwnPropertySymbols:tt}),T&&u(u.S+u.F*(!B||a(function(){var t=N();return"[null]"!=I([t])||"{}"!=I({a:t})||"{}"!=I(Object(t))})),"JSON",{stringify:function(t){if(void 0!==t&&!J(t)){for(var n,r,e=[t],i=1;arguments.length>i;)e.push(arguments[i++]);return n=e[1],"function"==typeof n&&(r=n),!r&&b(n)||(n=function(t,n){if(r&&(n=r.call(this,t,n)),!J(n))return n}),e[1]=n,I.apply(T,e)}}}),N[k][R]||r(27)(N[k],R,N[k].valueOf),l(N,"Symbol"),l(Math,"Math",!0),l(e.JSON,"JSON",!0)},function(t,n,r){"use strict";var e=r(1),i=r(127),o=r(152),u=r(2),c=r(75),f=r(16),a=r(6),s=r(3).ArrayBuffer,l=r(146),h=o.ArrayBuffer,v=o.DataView,p=i.ABV&&s.isView,d=h.prototype.slice,y=i.VIEW,g="ArrayBuffer";e(e.G+e.W+e.F*(s!==h),{ArrayBuffer:h}),e(e.S+e.F*!i.CONSTR,g,{isView:function(t){return p&&p(t)||a(t)&&y in t}}),e(e.P+e.U+e.F*r(4)(function(){return!new h(2).slice(1,void 0).byteLength}),g,{slice:function(t,n){if(void 0!==d&&void 0===n)return d.call(u(this),t);for(var r=u(this).byteLength,e=c(t,r),i=c(void 0===n?r:n,r),o=new(l(this,h))(f(i-e)),a=new v(this),s=new v(o),p=0;e<i;)s.setUint8(p++,a.getUint8(e++));return o}}),r(74)(g)},function(t,n,r){var e=r(1);e(e.G+e.W+e.F*!r(127).ABV,{DataView:r(152).DataView})},function(t,n,r){r(55)("Float32",4,function(t){return function(n,r,e){return t(this,n,r,e)}})},function(t,n,r){r(55)("Float64",8,function(t){return function(n,r,e){return t(this,n,r,e)}})},function(t,n,r){r(55)("Int16",2,function(t){return function(n,r,e){return t(this,n,r,e)}})},function(t,n,r){r(55)("Int32",4,function(t){return function(n,r,e){return t(this,n,r,e)}})},function(t,n,r){r(55)("Int8",1,function(t){return function(n,r,e){return t(this,n,r,e)}})},function(t,n,r){r(55)("Uint16",2,function(t){return function(n,r,e){return t(this,n,r,e)}})},function(t,n,r){r(55)("Uint32",4,function(t){return function(n,r,e){return t(this,n,r,e)}})},function(t,n,r){r(55)("Uint8",1,function(t){return function(n,r,e){return t(this,n,r,e)}})},function(t,n,r){r(55)("Uint8",1,function(t){return function(n,r,e){return t(this,n,r,e)}},!0)},function(t,n,r){"use strict";var e=r(166);r(118)("WeakSet",function(t){return function(){return t(this,arguments.length>0?arguments[0]:void 0)}},{add:function(t){return e.def(this,t,!0)}},e,!1,!0)},function(t,n,r){"use strict";var e=r(1),i=r(117)(!0);e(e.P,"Array",{includes:function(t){return i(this,t,arguments.length>1?arguments[1]:void 0)}}),r(78)("includes")},function(t,n,r){var e=r(1),i=r(143)(),o=r(3).process,u="process"==r(45)(o);e(e.G,{asap:function(t){var n=u&&o.domain;i(n?n.bind(t):t)}})},function(t,n,r){var e=r(1),i=r(45);e(e.S,"Error",{isError:function(t){return"Error"===i(t)}})},function(t,n,r){var e=r(1);e(e.P+e.R,"Map",{toJSON:r(165)("Map")})},function(t,n,r){var e=r(1);e(e.S,"Math",{iaddh:function(t,n,r,e){var i=t>>>0,o=n>>>0,u=r>>>0;return o+(e>>>0)+((i&u|(i|u)&~(i+u>>>0))>>>31)|0}})},function(t,n,r){var e=r(1);e(e.S,"Math",{imulh:function(t,n){var r=65535,e=+t,i=+n,o=e&r,u=i&r,c=e>>16,f=i>>16,a=(c*u>>>0)+(o*u>>>16);return c*f+(a>>16)+((o*f>>>0)+(a&r)>>16)}})},function(t,n,r){var e=r(1);e(e.S,"Math",{isubh:function(t,n,r,e){var i=t>>>0,o=n>>>0,u=r>>>0;return o-(e>>>0)-((~i&u|~(i^u)&i-u>>>0)>>>31)|0}})},function(t,n,r){var e=r(1);e(e.S,"Math",{umulh:function(t,n){var r=65535,e=+t,i=+n,o=e&r,u=i&r,c=e>>>16,f=i>>>16,a=(c*u>>>0)+(o*u>>>16);return c*f+(a>>>16)+((o*f>>>0)+(a&r)>>>16)}})},function(t,n,r){"use strict";var e=r(1),i=r(17),o=r(26),u=r(11);r(10)&&e(e.P+r(124),"Object",{__defineGetter__:function(t,n){u.f(i(this),t,{get:o(n),enumerable:!0,configurable:!0})}})},function(t,n,r){"use strict";var e=r(1),i=r(17),o=r(26),u=r(11);r(10)&&e(e.P+r(124),"Object",{__defineSetter__:function(t,n){u.f(i(this),t,{set:o(n),enumerable:!0,configurable:!0})}})},function(t,n,r){var e=r(1),i=r(176)(!0);e(e.S,"Object",{entries:function(t){return i(t)}})},function(t,n,r){var e=r(1),i=r(177),o=r(30),u=r(31),c=r(131);e(e.S,"Object",{getOwnPropertyDescriptors:function(t){for(var n,r=o(t),e=u.f,f=i(r),a={},s=0;f.length>s;)c(a,n=f[s++],e(r,n));return a}})},function(t,n,r){"use strict";var e=r(1),i=r(17),o=r(50),u=r(32),c=r(31).f;r(10)&&e(e.P+r(124),"Object",{__lookupGetter__:function(t){var n,r=i(this),e=o(t,!0);do{if(n=c(r,e))return n.get}while(r=u(r))}})},function(t,n,r){"use strict";var e=r(1),i=r(17),o=r(50),u=r(32),c=r(31).f;r(10)&&e(e.P+r(124),"Object",{__lookupSetter__:function(t){var n,r=i(this),e=o(t,!0);do{if(n=c(r,e))return n.set}while(r=u(r))}})},function(t,n,r){var e=r(1),i=r(176)(!1);e(e.S,"Object",{values:function(t){return i(t)}})},function(t,n,r){"use strict";var e=r(1),i=r(3),o=r(52),u=r(143)(),c=r(7)("observable"),f=r(26),a=r(2),s=r(68),l=r(73),h=r(27),v=r(79),p=v.RETURN,d=function(t){return null==t?void 0:f(t)},y=function(t){var n=t._c;n&&(t._c=void 0,n())},g=function(t){return void 0===t._o},b=function(t){g(t)||(t._o=void 0,y(t))},m=function(t,n){a(t),this._c=void 0,this._o=t,t=new x(this);try{var r=n(t),e=r;null!=r&&("function"==typeof r.unsubscribe?r=function(){e.unsubscribe()}:f(r),this._c=r)}catch(n){return void t.error(n)}g(this)&&y(this)};m.prototype=l({},{unsubscribe:function(){b(this)}});var x=function(t){this._s=t};x.prototype=l({},{next:function(t){var n=this._s;if(!g(n)){var r=n._o;try{var e=d(r.next);if(e)return e.call(r,t)}catch(t){try{b(n)}finally{throw t}}}},error:function(t){var n=this._s;if(g(n))throw t;var r=n._o;n._o=void 0;try{var e=d(r.error);if(!e)throw t;t=e.call(r,t)}catch(t){try{y(n)}finally{throw t}}return y(n),t},complete:function(t){var n=this._s;if(!g(n)){var r=n._o;n._o=void 0;try{var e=d(r.complete);t=e?e.call(r,t):void 0}catch(t){try{y(n)}finally{throw t}}return y(n),t}}});var w=function(t){s(this,w,"Observable","_f")._f=f(t)};l(w.prototype,{subscribe:function(t){return new m(t,this._f)},forEach:function(t){var n=this;return new(o.Promise||i.Promise)(function(r,e){f(t);var i=n.subscribe({next:function(n){try{return t(n)}catch(t){e(t),i.unsubscribe()}},error:e,complete:r})})}}),l(w,{from:function(t){var n="function"==typeof this?this:w,r=d(a(t)[c]);if(r){var e=a(r.call(t));return e.constructor===n?e:new n(function(t){return e.subscribe(t)})}return new n(function(n){var r=!1;return u(function(){if(!r){try{if(v(t,!1,function(t){if(n.next(t),r)return p})===p)return}catch(t){if(r)throw t;return void n.error(t)}n.complete()}}),function(){r=!0}})},of:function(){for(var t=0,n=arguments.length,r=Array(n);t<n;)r[t]=arguments[t++];return new("function"==typeof this?this:w)(function(t){var n=!1;return u(function(){if(!n){for(var e=0;e<r.length;++e)if(t.next(r[e]),n)return;t.complete()}}),function(){n=!0}})}}),h(w.prototype,c,function(){return this}),e(e.G,{Observable:w}),r(74)("Observable")},function(t,n,r){var e=r(54),i=r(2),o=e.key,u=e.set;e.exp({defineMetadata:function(t,n,r,e){u(t,n,i(r),o(e))}})},function(t,n,r){var e=r(54),i=r(2),o=e.key,u=e.map,c=e.store;e.exp({deleteMetadata:function(t,n){var r=arguments.length<3?void 0:o(arguments[2]),e=u(i(n),r,!1);if(void 0===e||!e.delete(t))return!1;if(e.size)return!0;var f=c.get(n);return f.delete(r),!!f.size||c.delete(n)}})},function(t,n,r){var e=r(185),i=r(161),o=r(54),u=r(2),c=r(32),f=o.keys,a=o.key,s=function(t,n){var r=f(t,n),o=c(t);if(null===o)return r;var u=s(o,n);return u.length?r.length?i(new e(r.concat(u))):u:r};o.exp({getMetadataKeys:function(t){return s(u(t),arguments.length<2?void 0:a(arguments[1]))}})},function(t,n,r){var e=r(54),i=r(2),o=r(32),u=e.has,c=e.get,f=e.key,a=function(t,n,r){if(u(t,n,r))return c(t,n,r);var e=o(n);return null!==e?a(t,e,r):void 0};e.exp({getMetadata:function(t,n){return a(t,i(n),arguments.length<3?void 0:f(arguments[2]))}})},function(t,n,r){var e=r(54),i=r(2),o=e.keys,u=e.key;e.exp({getOwnMetadataKeys:function(t){
return o(i(t),arguments.length<2?void 0:u(arguments[1]))}})},function(t,n,r){var e=r(54),i=r(2),o=e.get,u=e.key;e.exp({getOwnMetadata:function(t,n){return o(t,i(n),arguments.length<3?void 0:u(arguments[2]))}})},function(t,n,r){var e=r(54),i=r(2),o=r(32),u=e.has,c=e.key,f=function(t,n,r){if(u(t,n,r))return!0;var e=o(n);return null!==e&&f(t,e,r)};e.exp({hasMetadata:function(t,n){return f(t,i(n),arguments.length<3?void 0:c(arguments[2]))}})},function(t,n,r){var e=r(54),i=r(2),o=e.has,u=e.key;e.exp({hasOwnMetadata:function(t,n){return o(t,i(n),arguments.length<3?void 0:u(arguments[2]))}})},function(t,n,r){var e=r(54),i=r(2),o=r(26),u=e.key,c=e.set;e.exp({metadata:function(t,n){return function(r,e){c(t,n,(void 0!==e?i:o)(r),u(e))}}})},function(t,n,r){var e=r(1);e(e.P+e.R,"Set",{toJSON:r(165)("Set")})},function(t,n,r){"use strict";var e=r(1),i=r(147)(!0);e(e.P,"String",{at:function(t){return i(this,t)}})},function(t,n,r){"use strict";var e=r(1),i=r(46),o=r(16),u=r(122),c=r(120),f=RegExp.prototype,a=function(t,n){this._r=t,this._s=n};r(139)(a,"RegExp String",function(){var t=this._r.exec(this._s);return{value:t,done:null===t}}),e(e.P,"String",{matchAll:function(t){if(i(this),!u(t))throw TypeError(t+" is not a regexp!");var n=String(this),r="flags"in f?String(t.flags):c.call(t),e=new RegExp(t.source,~r.indexOf("g")?r:"g"+r);return e.lastIndex=o(t.lastIndex),new a(e,n)}})},function(t,n,r){"use strict";var e=r(1),i=r(181);e(e.P,"String",{padEnd:function(t){return i(this,t,arguments.length>1?arguments[1]:void 0,!1)}})},function(t,n,r){"use strict";var e=r(1),i=r(181);e(e.P,"String",{padStart:function(t){return i(this,t,arguments.length>1?arguments[1]:void 0,!0)}})},function(t,n,r){"use strict";r(82)("trimLeft",function(t){return function(){return t(this,1)}},"trimStart")},function(t,n,r){"use strict";r(82)("trimRight",function(t){return function(){return t(this,2)}},"trimEnd")},function(t,n,r){r(153)("asyncIterator")},function(t,n,r){r(153)("observable")},function(t,n,r){var e=r(1);e(e.S,"System",{global:r(3)})},function(t,n,r){for(var e=r(155),i=r(28),o=r(3),u=r(27),c=r(80),f=r(7),a=f("iterator"),s=f("toStringTag"),l=c.Array,h=["NodeList","DOMTokenList","MediaList","StyleSheetList","CSSRuleList"],v=0;v<5;v++){var p,d=h[v],y=o[d],g=y&&y.prototype;if(g){g[a]||u(g,a,l),g[s]||u(g,s,d),c[d]=l;for(p in e)g[p]||i(g,p,e[p],!0)}}},function(t,n,r){var e=r(1),i=r(151);e(e.G+e.B,{setImmediate:i.set,clearImmediate:i.clear})},function(t,n,r){var e=r(3),i=r(1),o=r(121),u=r(207),c=e.navigator,f=!!c&&/MSIE .\./.test(c.userAgent),a=function(t){return f?function(n,r){return t(o(u,[].slice.call(arguments,2),"function"==typeof n?n:Function(n)),r)}:t};i(i.G+i.B+i.F*f,{setTimeout:a(e.setTimeout),setInterval:a(e.setInterval)})},function(t,n,r){r(330),r(269),r(271),r(270),r(273),r(275),r(280),r(274),r(272),r(282),r(281),r(277),r(278),r(276),r(268),r(279),r(283),r(284),r(236),r(238),r(237),r(286),r(285),r(256),r(266),r(267),r(257),r(258),r(259),r(260),r(261),r(262),r(263),r(264),r(265),r(239),r(240),r(241),r(242),r(243),r(244),r(245),r(246),r(247),r(248),r(249),r(250),r(251),r(252),r(253),r(254),r(255),r(317),r(322),r(329),r(320),r(312),r(313),r(318),r(323),r(325),r(308),r(309),r(310),r(311),r(314),r(315),r(316),r(319),r(321),r(324),r(326),r(327),r(328),r(231),r(233),r(232),r(235),r(234),r(220),r(218),r(224),r(221),r(227),r(229),r(217),r(223),r(214),r(228),r(212),r(226),r(225),r(219),r(222),r(211),r(213),r(216),r(215),r(230),r(155),r(302),r(307),r(184),r(303),r(304),r(305),r(306),r(287),r(183),r(185),r(186),r(342),r(331),r(332),r(337),r(340),r(341),r(335),r(338),r(336),r(339),r(333),r(334),r(288),r(289),r(290),r(291),r(292),r(295),r(293),r(294),r(296),r(297),r(298),r(299),r(301),r(300),r(343),r(369),r(372),r(371),r(373),r(374),r(370),r(375),r(376),r(354),r(357),r(353),r(351),r(352),r(355),r(356),r(346),r(368),r(377),r(345),r(347),r(349),r(348),r(350),r(359),r(360),r(362),r(361),r(364),r(363),r(365),r(366),r(367),r(344),r(358),r(380),r(379),r(378),t.exports=r(52)},function(t,n){function r(t,n){if("string"==typeof n)return t.insertAdjacentHTML("afterend",n);var r=t.nextSibling;return r?t.parentNode.insertBefore(n,r):t.parentNode.appendChild(n)}t.exports=r},,,,,,,,,function(t,n,r){(function(n,r){!function(n){"use strict";function e(t,n,r,e){var i=n&&n.prototype instanceof o?n:o,u=Object.create(i.prototype),c=new p(e||[]);return u._invoke=s(t,r,c),u}function i(t,n,r){try{return{type:"normal",arg:t.call(n,r)}}catch(t){return{type:"throw",arg:t}}}function o(){}function u(){}function c(){}function f(t){["next","throw","return"].forEach(function(n){t[n]=function(t){return this._invoke(n,t)}})}function a(t){function n(r,e,o,u){var c=i(t[r],t,e);if("throw"!==c.type){var f=c.arg,a=f.value;return a&&"object"==typeof a&&m.call(a,"__await")?Promise.resolve(a.__await).then(function(t){n("next",t,o,u)},function(t){n("throw",t,o,u)}):Promise.resolve(a).then(function(t){f.value=t,o(f)},u)}u(c.arg)}function e(t,r){function e(){return new Promise(function(e,i){n(t,r,e,i)})}return o=o?o.then(e,e):e()}"object"==typeof r&&r.domain&&(n=r.domain.bind(n));var o;this._invoke=e}function s(t,n,r){var e=P;return function(o,u){if(e===F)throw new Error("Generator is already running");if(e===M){if("throw"===o)throw u;return y()}for(r.method=o,r.arg=u;;){var c=r.delegate;if(c){var f=l(c,r);if(f){if(f===A)continue;return f}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(e===P)throw e=M,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);e=F;var a=i(t,n,r);if("normal"===a.type){if(e=r.done?M:j,a.arg===A)continue;return{value:a.arg,done:r.done}}"throw"===a.type&&(e=M,r.method="throw",r.arg=a.arg)}}}function l(t,n){var r=t.iterator[n.method];if(r===g){if(n.delegate=null,"throw"===n.method){if(t.iterator.return&&(n.method="return",n.arg=g,l(t,n),"throw"===n.method))return A;n.method="throw",n.arg=new TypeError("The iterator does not provide a 'throw' method")}return A}var e=i(r,t.iterator,n.arg);if("throw"===e.type)return n.method="throw",n.arg=e.arg,n.delegate=null,A;var o=e.arg;return o?o.done?(n[t.resultName]=o.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=g),n.delegate=null,A):o:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,A)}function h(t){var n={tryLoc:t[0]};1 in t&&(n.catchLoc=t[1]),2 in t&&(n.finallyLoc=t[2],n.afterLoc=t[3]),this.tryEntries.push(n)}function v(t){var n=t.completion||{};n.type="normal",delete n.arg,t.completion=n}function p(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(h,this),this.reset(!0)}function d(t){if(t){var n=t[w];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,e=function n(){for(;++r<t.length;)if(m.call(t,r))return n.value=t[r],n.done=!1,n;return n.value=g,n.done=!0,n};return e.next=e}}return{next:y}}function y(){return{value:g,done:!0}}var g,b=Object.prototype,m=b.hasOwnProperty,x="function"==typeof Symbol?Symbol:{},w=x.iterator||"@@iterator",S=x.asyncIterator||"@@asyncIterator",_=x.toStringTag||"@@toStringTag",O="object"==typeof t,E=n.regeneratorRuntime;if(E)return void(O&&(t.exports=E));E=n.regeneratorRuntime=O?t.exports:{},E.wrap=e;var P="suspendedStart",j="suspendedYield",F="executing",M="completed",A={},N={};N[w]=function(){return this};var T=Object.getPrototypeOf,I=T&&T(T(d([])));I&&I!==b&&m.call(I,w)&&(N=I);var k=c.prototype=o.prototype=Object.create(N);u.prototype=k.constructor=c,c.constructor=u,c[_]=u.displayName="GeneratorFunction",E.isGeneratorFunction=function(t){var n="function"==typeof t&&t.constructor;return!!n&&(n===u||"GeneratorFunction"===(n.displayName||n.name))},E.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,c):(t.__proto__=c,_ in t||(t[_]="GeneratorFunction")),t.prototype=Object.create(k),t},E.awrap=function(t){return{__await:t}},f(a.prototype),a.prototype[S]=function(){return this},E.AsyncIterator=a,E.async=function(t,n,r,i){var o=new a(e(t,n,r,i));return E.isGeneratorFunction(n)?o:o.next().then(function(t){return t.done?t.value:o.next()})},f(k),k[_]="Generator",k.toString=function(){return"[object Generator]"},E.keys=function(t){var n=[];for(var r in t)n.push(r);return n.reverse(),function r(){for(;n.length;){var e=n.pop();if(e in t)return r.value=e,r.done=!1,r}return r.done=!0,r}},E.values=d,p.prototype={constructor:p,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=g,this.done=!1,this.delegate=null,this.method="next",this.arg=g,this.tryEntries.forEach(v),!t)for(var n in this)"t"===n.charAt(0)&&m.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=g)},stop:function(){this.done=!0;var t=this.tryEntries[0],n=t.completion;if("throw"===n.type)throw n.arg;return this.rval},dispatchException:function(t){function n(n,e){return o.type="throw",o.arg=t,r.next=n,e&&(r.method="next",r.arg=g),!!e}if(this.done)throw t;for(var r=this,e=this.tryEntries.length-1;e>=0;--e){var i=this.tryEntries[e],o=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var u=m.call(i,"catchLoc"),c=m.call(i,"finallyLoc");if(u&&c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,n){for(var r=this.tryEntries.length-1;r>=0;--r){var e=this.tryEntries[r];if(e.tryLoc<=this.prev&&m.call(e,"finallyLoc")&&this.prev<e.finallyLoc){var i=e;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=n&&n<=i.finallyLoc&&(i=null);var o=i?i.completion:{};return o.type=t,o.arg=n,i?(this.method="next",this.next=i.finallyLoc,A):this.complete(o)},complete:function(t,n){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&n&&(this.next=n),A},finish:function(t){for(var n=this.tryEntries.length-1;n>=0;--n){var r=this.tryEntries[n];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),v(r),A}},catch:function(t){for(var n=this.tryEntries.length-1;n>=0;--n){var r=this.tryEntries[n];if(r.tryLoc===t){var e=r.completion;if("throw"===e.type){var i=e.arg;v(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:d(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=g),A}}}("object"==typeof n?n:"object"==typeof window?window:"object"==typeof self?self:this)}).call(n,function(){return this}(),r(158))}])</script><script src="/./main.0cf68a.js"></script><script>!function(){!function(e){var t=document.createElement("script");document.getElementsByTagName("body")[0].appendChild(t),t.setAttribute("src",e)}("/slider.e37972.js")}()</script>


<script type="text/x-mathjax-config">
MathJax.Hub.Config({
    tex2jax: {
        inlineMath: [ ['$','$'], ["\\(","\\)"]  ],
        processEscapes: true,
        skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
    }
});

MathJax.Hub.Queue(function() {
    var all = MathJax.Hub.getAllJax(), i;
    for(i=0; i < all.length; i += 1) {
        all[i].SourceElement().parentNode.className += ' has-jax';                 
    }       
});
</script>

<script src="//cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>


    
<div class="tools-col" q-class="show:isShow,hide:isShow|isFalse" q-on="click:stop(e)">
  <div class="tools-nav header-menu">
    
    
      
      
      
    
      
      
      
    
      
      
      
    
    

    <ul style="width: 70%">
    
    
      
      <li style="width: 33.333333333333336%" q-on="click: openSlider(e, 'innerArchive')"><a href="javascript:void(0)" q-class="active:innerArchive">所有文章</a></li>
      
        
      
      <li style="width: 33.333333333333336%" q-on="click: openSlider(e, 'friends')"><a href="javascript:void(0)" q-class="active:friends">友链</a></li>
      
        
      
      <li style="width: 33.333333333333336%" q-on="click: openSlider(e, 'aboutme')"><a href="javascript:void(0)" q-class="active:aboutme">关于我</a></li>
      
        
    </ul>
  </div>
  <div class="tools-wrap">
    
    	<section class="tools-section tools-section-all" q-show="innerArchive">
        <div class="search-wrap">
          <input class="search-ipt" q-model="search" type="text" placeholder="find something…">
          <i class="icon-search icon" q-show="search|isEmptyStr"></i>
          <i class="icon-close icon" q-show="search|isNotEmptyStr" q-on="click:clearChose(e)"></i>
        </div>
        <div class="widget tagcloud search-tag">
          <p class="search-tag-wording">tag:</p>
          <label class="search-switch">
            <input type="checkbox" q-on="click:toggleTag(e)" q-attr="checked:showTags">
          </label>
          <ul class="article-tag-list" q-show="showTags">
             
              <li class="article-tag-list-item">
                <a href="javascript:void(0)" class="js-tag color1">C/C++</a>
              </li>
             
              <li class="article-tag-list-item">
                <a href="javascript:void(0)" class="js-tag color4">Git</a>
              </li>
             
              <li class="article-tag-list-item">
                <a href="javascript:void(0)" class="js-tag color1">Linux</a>
              </li>
             
              <li class="article-tag-list-item">
                <a href="javascript:void(0)" class="js-tag color3">Manjaro</a>
              </li>
             
              <li class="article-tag-list-item">
                <a href="javascript:void(0)" class="js-tag color4">Desktop Entry</a>
              </li>
             
              <li class="article-tag-list-item">
                <a href="javascript:void(0)" class="js-tag color4">STL</a>
              </li>
             
              <li class="article-tag-list-item">
                <a href="javascript:void(0)" class="js-tag color3">Qt</a>
              </li>
             
              <li class="article-tag-list-item">
                <a href="javascript:void(0)" class="js-tag color1">MySql</a>
              </li>
             
              <li class="article-tag-list-item">
                <a href="javascript:void(0)" class="js-tag color4">Markdown</a>
              </li>
             
              <li class="article-tag-list-item">
                <a href="javascript:void(0)" class="js-tag color2">Hello World</a>
              </li>
             
              <li class="article-tag-list-item">
                <a href="javascript:void(0)" class="js-tag color3">前端</a>
              </li>
             
              <li class="article-tag-list-item">
                <a href="javascript:void(0)" class="js-tag color5">Hexo</a>
              </li>
             
              <li class="article-tag-list-item">
                <a href="javascript:void(0)" class="js-tag color4">WSL</a>
              </li>
             
              <li class="article-tag-list-item">
                <a href="javascript:void(0)" class="js-tag color3">Windows</a>
              </li>
            
            <div class="clearfix"></div>
          </ul>
        </div>
        <ul class="search-ul">
          <p q-show="jsonFail" style="padding: 20px; font-size: 12px;">
            缺失模块。<br/>1、请确保node版本大于6.2<br/>2、在博客根目录（注意不是yilia根目录）执行以下命令：<br/> npm i hexo-generator-json-content --save<br/><br/>
            3、在根目录_config.yml里添加配置：
<pre style="font-size: 12px;" q-show="jsonFail">
  jsonContent:
    meta: false
    pages: false
    posts:
      title: true
      date: true
      path: true
      text: false
      raw: false
      content: false
      slug: false
      updated: false
      comments: false
      link: false
      permalink: false
      excerpt: false
      categories: false
      tags: true
</pre>
          </p>
          <li class="search-li" q-repeat="items" q-show="isShow">
            <a q-attr="href:path|urlformat" class="search-title"><i class="icon-quo-left icon"></i><span q-text="title"></span></a>
            <p class="search-time">
              <i class="icon-calendar icon"></i>
              <span q-text="date|dateformat"></span>
            </p>
            <p class="search-tag">
              <i class="icon-price-tags icon"></i>
              <span q-repeat="tags" q-on="click:choseTag(e, name)" q-text="name|tagformat"></span>
            </p>
          </li>
        </ul>
    	</section>
    

    
    	<section class="tools-section tools-section-friends" q-show="friends">
  		
        <ul class="search-ul">
          
            <li class="search-li">
              <a href="http://www.cqupt.edu.cn/" target="_blank" class="search-title"><i class="icon-quo-left icon"></i>重庆邮电大学</a>
            </li>
          
            <li class="search-li">
              <a href="http://ac.cqupt.edu.cn/" target="_blank" class="search-title"><i class="icon-quo-left icon"></i>重邮自动化学院</a>
            </li>
          
            <li class="search-li">
              <a href="https://space.bilibili.com/20259914?spm_id_from=333.337.0.0" target="_blank" class="search-title"><i class="icon-quo-left icon"></i>稚晖君B站首页</a>
            </li>
          
            <li class="search-li">
              <a href="https://space.bilibili.com/254463269?spm_id_from=333.337.0.0" target="_blank" class="search-title"><i class="icon-quo-left icon"></i>毕导B站首页</a>
            </li>
          
            <li class="search-li">
              <a href="https://blog.csdn.net/qq_40567501?spm=1000.2115.3001.5343" target="_blank" class="search-title"><i class="icon-quo-left icon"></i>我的CSDN首页</a>
            </li>
          
        </ul>
  		
    	</section>
    

    
    	<section class="tools-section tools-section-me" q-show="aboutme">
  	  	
  	  		<div class="aboutme-wrap" id="js-aboutme">层云叠嶂&lt;br&gt;&lt;br&gt;你也别慌&lt;br&gt;&lt;br&gt;有一段月光&lt;br&gt;&lt;br&gt;穿破迷惘&lt;br&gt;&lt;br&gt;陪你到天亮</div>
  	  	
    	</section>
    
  </div>
  
</div>
    <!-- Root element of PhotoSwipe. Must have class pswp. -->
<div class="pswp" tabindex="-1" role="dialog" aria-hidden="true">

    <!-- Background of PhotoSwipe. 
         It's a separate element as animating opacity is faster than rgba(). -->
    <div class="pswp__bg"></div>

    <!-- Slides wrapper with overflow:hidden. -->
    <div class="pswp__scroll-wrap">

        <!-- Container that holds slides. 
            PhotoSwipe keeps only 3 of them in the DOM to save memory.
            Don't modify these 3 pswp__item elements, data is added later on. -->
        <div class="pswp__container">
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
        </div>

        <!-- Default (PhotoSwipeUI_Default) interface on top of sliding area. Can be changed. -->
        <div class="pswp__ui pswp__ui--hidden">

            <div class="pswp__top-bar">

                <!--  Controls are self-explanatory. Order can be changed. -->

                <div class="pswp__counter"></div>

                <button class="pswp__button pswp__button--close" title="Close (Esc)"></button>

                <button class="pswp__button pswp__button--share" style="display:none" title="Share"></button>

                <button class="pswp__button pswp__button--fs" title="Toggle fullscreen"></button>

                <button class="pswp__button pswp__button--zoom" title="Zoom in/out"></button>

                <!-- Preloader demo http://codepen.io/dimsemenov/pen/yyBWoR -->
                <!-- element will get class pswp__preloader--active when preloader is running -->
                <div class="pswp__preloader">
                    <div class="pswp__preloader__icn">
                      <div class="pswp__preloader__cut">
                        <div class="pswp__preloader__donut"></div>
                      </div>
                    </div>
                </div>
            </div>

            <div class="pswp__share-modal pswp__share-modal--hidden pswp__single-tap">
                <div class="pswp__share-tooltip"></div> 
            </div>

            <button class="pswp__button pswp__button--arrow--left" title="Previous (arrow left)">
            </button>

            <button class="pswp__button pswp__button--arrow--right" title="Next (arrow right)">
            </button>

            <div class="pswp__caption">
                <div class="pswp__caption__center"></div>
            </div>

        </div>

    </div>

</div>
  </div>
</body>
</html>